Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Troubleshooting Javascript. Object Expected.

Reply
Thread Tools

Troubleshooting Javascript. Object Expected.

 
 
jobs
Guest
Posts: n/a
 
      10-13-2007
I've got some javascript that works great in some old asp.net 1.0
inline code. I'm attempting to move the javascript to an asp.net
masterpage and use it in a content page. I understand this is not an
asp.net forum.


I'm looking at the rendered page and am not sure why i'm getting that
common Object expected message.

But mainly my question is about troubleshooting javascript in general.
What tools do you use? is there a console of IE to figure out where
this error is happening exactly

What it's suppose to do is display an image, and then do a slideshow
(blending) of 5 images. It only shows the first image and then chokes.
This code was working fine before I moved the javascript to the
asp.net master page.

Thank you for any help!


My error: reads

Line 27 (which appears to be my body tag)
Char1
Error: object expected




Rendered HTML.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head><title>
Untitled Page
</title><style type="text/css">
.ctl00_Menu1_0 { background-
color:white;visibility:hidden;display:none;positio n:absolute;left:
0px;top:0px; }
.ctl00_Menu1_1 { color:#666666;font-family:Verdana;font-size:
0.8em;text-decoration:none; }
.ctl00_Menu1_2 { color:#666666;background-color:#E3EAEB;font-
family:Verdana;font-size:0.8em; }
.ctl00_Menu1_3 { }
.ctl00_Menu1_4 { padding:2px 5px 2px 5px; }
.ctl00_Menu1_5 { }
.ctl00_Menu1_6 { padding:2px 5px 2px 5px; }
.ctl00_Menu1_7 { background-color:#E3EAEB; }
.ctl00_Menu1_8 { }
.ctl00_Menu1_9 { background-color:#1C5E55; }
.ctl00_Menu1_10 { }
.ctl00_Menu1_11 { background-color:#1C5E55; }
.ctl00_Menu1_12 { color:White; }
.ctl00_Menu1_13 { color:White;background-color:#666666; }
.ctl00_Menu1_14 { color:White; }
.ctl00_Menu1_15 { color:White;background-color:#666666; }

</style></head>
<body id="ctl00_Body" onload="SetTimeout('slideit()',5000);">

<div style="font-size: 20pt; left: 74px; width: 722px; color:
navy; font-family: Georgia;
position: absolute; top: 12px; height: 132px">
some content here</div>
<br />
<br />
<br />
<br />
<br />
<br />
<form name="aspnetForm" method="post" action="Default.aspx"
id="aspnetForm">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /
>

<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT"
value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/
wEPDwUJLTI0MTM1MTE4D2QWAmYPZBYCAgMPFgIeBm9ubG9hZAU dU2V0VGltZW91dCgnc2xpZGVpdCgpJyw1MDAwKTtkZMeWyaebL 7+2mGx5IlUTJG74K3K/" /
>

</div>

<script type="text/javascript">
<!--
var theForm = document.forms['aspnetForm'];
if (!theForm) {
theForm = document.aspnetForm;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
// -->
</script>


<script src="/Ruben/WebResource.axd?
d=4U6X6OcF978CdaNo3fWogA2&amp;t=633042420571718750 " type="text/
javascript"></script>


<script src="/Ruben/WebResource.axd?
d=nm6ynZk2X7rH-6bHnDMszQ2&amp;t=633042420571718750" type="text/
javascript"></script>
<a href="#ctl00_Menu1_SkipLink"><img alt="Skip Navigation Links"
src="/Ruben/WebResource.axd?
d=L7v_eVgTP2teHMJYvWOWpQ2&amp;t=633042420571718750 " width="0"
height="0" style="border-width:0px;" /></a><table id="ctl00_Menu1"
class="ctl00_Menu1_2" cellpadding="0" cellspacing="0" border="0"
style="left: 11px; position: absolute; top: 15px">
<tr onmouseover="Menu_HoverStatic(this)"
onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)" title="Home"
id="ctl00_Menu1n0">
<td><table class="ctl00_Menu1_4" cellpadding="0" cellspacing="0"
border="0" width="100%">
<tr>
<td style="white-space:nowrap;width:100%;"><a class="ctl00_Menu1_1
ctl00_Menu1_3" href="default.aspx">Home</a></td>
</tr>
</table></td>
</tr><tr onmouseover="Menu_HoverStatic(this)"
onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)"
id="ctl00_Menu1n1">
<td><table class="ctl00_Menu1_4" cellpadding="0" cellspacing="0"
border="0" width="100%">
<tr>
<td style="white-space:nowrap;width:100%;"><a class="ctl00_Menu1_1
ctl00_Menu1_3" href="photos.aspx">Photos</a></td>
</tr>
</table></td>
</tr>
</table><a id="ctl00_Menu1_SkipLink"></a>
<div style="width:720px;height:400px; left: 77px; position:
absolute; top: 154px;">


<img id="ctl00_Content1_cool" src="medium.aspx?src=images/c1.jpg"
style="height:400px;width:400px;border-width:0px;WIDTH:400px;Height:
400px;filter:blendTrans(duration=3)" />

</div>


<script type="text/javascript">
<!--
var ctl00_Menu1_Data = new Object();
ctl00_Menu1_Data.disappearAfter = 500;
ctl00_Menu1_Data.horizontalOffset = 2;
ctl00_Menu1_Data.verticalOffset = 0;
ctl00_Menu1_Data.hoverClass = 'ctl00_Menu1_15';
ctl00_Menu1_Data.hoverHyperLinkClass = 'ctl00_Menu1_14';
ctl00_Menu1_Data.staticHoverClass = 'ctl00_Menu1_13';
ctl00_Menu1_Data.staticHoverHyperLinkClass = 'ctl00_Menu1_12';
// -->
</script>
</form>
</body>
</html>

<script type="text/javascript">

<!--
var step=1
var whichimage=1
//preload images
var image1=new Image()
image1.src="medium.aspx?src=images/c1.JPG"
var image2=new Image()
image2.src="medium.aspx?src=images/c2.JPG"
var image3=new Image()
image3.src="medium.aspx?src=images/c3.JPG"
var image4=new Image()
image4.src="medium.aspx?src=images/c4.JPG"
var image5=new Image()
image5.src="medium.aspx?src=images/c5.jpg"


function slideit(){
if (!document.images)
return
//If the browser is IE 4.x
if (document.all)
ctl00_Content1_cool.filters.blendTrans.apply()
document.images.ctl00_Content1_cool.src=eval("imag e"+step+".src")
//If the browser is IE 4.x
if (document.all)
ctl00_Content1_cool.filters.blendTrans.play()
whichimage=step
if (step<
step++
else
step=1
setTimeout("slideit()",5000)
}
//-->
</script>

 
Reply With Quote
 
 
 
 
David Mark
Guest
Posts: n/a
 
      10-13-2007
On Oct 13, 11:22 am, jobs <(E-Mail Removed)> wrote:
> I've got some javascript that works great in some old asp.net 1.0
> inline code. I'm attempting to move the javascript to an asp.net
> masterpage and use it in a content page. I understand this is not an
> asp.net forum.
>
> I'm looking at the rendered page and am not sure why i'm getting that
> common Object expected message.
>
> But mainly my question is about troubleshooting javascript in general.
> What tools do you use? is there a console of IE to figure out where


Visual Studio is one option. I believe there is a stand-alone script
debugger as well.

> this error is happening exactly
>
> What it's suppose to do is display an image, and then do a slideshow
> (blending) of 5 images. It only shows the first image and then chokes.
> This code was working fine before I moved the javascript to the
> asp.net master page.
>
> Thank you for any help!
>
> My error: reads
>
> Line 27 (which appears to be my body tag)
> Char1
> Error: object expected
>
> Rendered HTML.
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


Are you really transitioning this to XHTML?

>
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head><title>
> Untitled Page
> </title><style type="text/css">
> .ctl00_Menu1_0 { background-
> color:white;visibility:hidden;display:none;positio n:absolute;left:
> 0px;top:0px; }
> .ctl00_Menu1_1 { color:#666666;font-family:Verdana;font-size:
> 0.8em;text-decoration:none; }
> .ctl00_Menu1_2 { color:#666666;background-color:#E3EAEB;font-
> family:Verdana;font-size:0.8em; }
> .ctl00_Menu1_3 { }
> .ctl00_Menu1_4 { padding:2px 5px 2px 5px; }
> .ctl00_Menu1_5 { }
> .ctl00_Menu1_6 { padding:2px 5px 2px 5px; }
> .ctl00_Menu1_7 { background-color:#E3EAEB; }
> .ctl00_Menu1_8 { }
> .ctl00_Menu1_9 { background-color:#1C5E55; }
> .ctl00_Menu1_10 { }
> .ctl00_Menu1_11 { background-color:#1C5E55; }
> .ctl00_Menu1_12 { color:White; }
> .ctl00_Menu1_13 { color:White;background-color:#666666; }
> .ctl00_Menu1_14 { color:White; }
> .ctl00_Menu1_15 { color:White;background-color:#666666; }
>
> </style></head>
> <body id="ctl00_Body" onload="SetTimeout('slideit()',5000);">


Why wait 5 seconds?

>
> <div style="font-size: 20pt; left: 74px; width: 722px; color:
> navy; font-family: Georgia;
> position: absolute; top: 12px; height: 132px">
> some content here</div>
> <br />
> <br />
> <br />
> <br />
> <br />
> <br />


How many times can you break a line? Use CSS for margins.

> <form name="aspnetForm" method="post" action="Default.aspx"
> id="aspnetForm">
> <div>
> <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /
>
> <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT"
> value="" />
> <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/
> wEPDwUJLTI0MTM1MTE4D2QWAmYPZBYCAgMPFgIeBm9ubG9hZAU dU2V0VGltZW91dCgnc2xpZGVp*dCgpJyw1MDAwKTtkZMeWyaeb L7+2mGx5IlUTJG74K3K/" /
>
> </div>
>
> <script type="text/javascript">
> <!--


This comment delimiter won't work for XHTML and is unnecessary for
HTML.

[snip]

>
> function slideit(){
> if (!document.images)
> return


You don't need this test.

> //If the browser is IE 4.x
> if (document.all)


This test is nonsense. Opera (among others) supports document.all.

> ctl00_Content1_cool.filters.blendTrans.apply()


Use getElementById to get a reference to the image element. Then test
the filters object and make sure it has at least one member (and that
it has a blendTrans property.) Filters are present when they are
defined in the CSS or added with script. I suspect that the previous
content had filters defined in a style sheet. Scripts shouldn't rely
on a specific style to run.

> document.images.ctl00_Content1_cool.src=eval("imag e"+step+".src")


Why eval?

> //If the browser is IE 4.x
> if (document.all)
> ctl00_Content1_cool.filters.blendTrans.play()


See above.

> whichimage=step
> if (step<
> step++
> else
> step=1
> setTimeout("slideit()",5000)}


setTimeout will take a function object as its first parameter.
Perhaps not in IE4 though.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Troubleshooting frozen object in tzinfo_timezone Morten Ruby 0 01-30-2007 12:10 AM
Object creation - Do we really need to create a parent for a derieved object - can't the base object just point to an already created base object jon wayne C++ 9 09-22-2005 02:06 AM
Troubleshooting: re.finditer() creates object even when no match found Chris Lasher Python 8 12-18-2004 12:51 PM
Re: Home network troubleshooting jonjo Wireless Networking 0 07-06-2004 08:51 AM
Troubleshooting Object Reference Not Set to Instance of an Object =?Utf-8?B?TG9yaSBNY0RvbmFsZA==?= ASP .Net 3 04-10-2004 09:12 PM



Advertisments