Troubleshooting Javascript. Object Expected.

Discussion in 'Javascript' started by jobs, Oct 13, 2007.

  1. jobs

    jobs Guest

    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;position: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="/
    wEPDwUJLTI0MTM1MTE4D2QWAmYPZBYCAgMPFgIeBm9ubG9hZAUdU2V0VGltZW91dCgnc2xpZGVpdCgpJyw1MDAwKTtkZMeWyaebL7+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("image"+step+".src")
    //If the browser is IE 4.x
    if (document.all)
    ctl00_Content1_cool.filters.blendTrans.play()
    whichimage=step
    if (step<8)
    step++
    else
    step=1
    setTimeout("slideit()",5000)
    }
    //-->
    </script>
    jobs, Oct 13, 2007
    #1
    1. Advertising

  2. jobs

    David Mark Guest

    On Oct 13, 11:22 am, jobs <> 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;position: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="/
    > wEPDwUJLTI0MTM1MTE4D2QWAmYPZBYCAgMPFgIeBm9ubG9hZAUdU2V0VGltZW91dCgnc2xpZGVp­dCgpJyw1MDAwKTtkZMeWyaebL7+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("image"+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<8)
    > step++
    > else
    > step=1
    > setTimeout("slideit()",5000)}


    setTimeout will take a function object as its first parameter.
    Perhaps not in IE4 though.
    David Mark, Oct 13, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TG9yaSBNY0RvbmFsZA==?=

    Troubleshooting Object Reference Not Set to Instance of an Object

    =?Utf-8?B?TG9yaSBNY0RvbmFsZA==?=, Apr 9, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    470
    MS News \(MS ILM\)
    Apr 10, 2004
  2. MattB

    javascript troubleshooting

    MattB, Nov 23, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    620
    MattB
    Nov 24, 2005
  3. Chris Lasher
    Replies:
    8
    Views:
    339
    Michael Hoffman
    Dec 18, 2004
  4. jobs

    Troubleshooting Javascript

    jobs, Oct 13, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    755
    bruce barker
    Oct 13, 2007
  5. Morten
    Replies:
    0
    Views:
    89
    Morten
    Jan 30, 2007
Loading...

Share This Page