Tech Off Thread

15 posts

missing ) after argument list

Back to Forum: Tech Off
  • User profile image
    mrichman

    Why is Firefox complaining with this error:

    ------------------------------------------------------------
    missing ) after argument list

    setTimeout('breakOut',5000);   
    ------------------------------------------------------------


    Here is the HTML that I'm producing:

    <html>
    <head>
    <script type="text/javascript">
    <!--
     function breakOut() {
     top.location.href = 'https://foo.com';
    }
    // -->
    </script>
    <body onLoad="setTimeout('breakOut()',5ØØØ);">
    You have been logged out of the control panel due to inactivity for your security.
    </body>
    </html>

  • User profile image
    Maurits

    two possibilities...

    it doesn't like the // in the URL... try breaking it up as 'https:/' + '/...'
    it doesn't like the Ø ... or is that a transcription error?

  • User profile image
    W3bbo

    mrichman wrote:
    Why is Firefox complaining with this error:

    ------------------------------------------------------------
    missing ) after argument list

    setTimeout('breakOut',5000);   
    ------------------------------------------------------------

    Here is the HTML that I'm producing:

    <html>
    <head>
    <script type="text/javascript">
    <!--
     function breakOut() {
     top.location.href = 'https://foo.com';
    }
    // -->
    </script>
    <body onLoad="setTimeout('breakOut()',5ØØØ);">
    You have been logged out of the control panel due to inactivity for your security.
    </body>
    </html>


    Not solving the direct issue you're having, but I think showing a message box or positioned box on the page would be better than changing the location of the browser's window.

    HCI and all that Smiley

  • User profile image
    mrichman

    My problem was that those 000's were in fact not zeros (got bit by the cut 'n paste bug).

    I also changed top.location.href to top.location on the recommendation that it is sufficient and not prone to the "Same Origin Policy".

    Someone also mentioned that the <!-- // --> pair was unnecessary and potentially harmful...can someone explain?

  • User profile image
    Maurits

    <!-- // --> was invented for two reasons:

    1) to stop the javascript code from showing up on user agents that didn't understand the "<script>" tag but which did understand comments (search engine bots, IE 2, that kind of thing.)

    2) to allow unescaped &'s for && without invalidating the HTML-ness of the document

    The XHTML way to do inline scripting is with <[!CDATA[...]]> blocks.

    The XHTML/HTML-compatible way is to use exclusively <script src="..."> external script blocks.

    EDIT: Oh, also javascript "i--" things have weird effects with HTML comments.  Technically the SGML comment delimiter is --, not <!-- and -->.

  • User profile image
    mrichman

    If it's such poor practice to use <!-- // --> then why does Microsoft do this as part of ASP.NET's plumbing?

    <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>

  • User profile image
    Maurits

    Don't get me started on ASP.NET...
    I happen to think it's poor practice to require form submittal and javascript just to go to page 2 of a list.

  • User profile image
    W3bbo

    Maurits wrote:
    Don't get me started on ASP.NET...
    I happen to think it's poor practice to require form submittal and javascript just to go to page 2 of a list.


    That's what querystring was invented for, but since devising even the most simplist of querystring systems requires (OMG!) editing raw code (and Microsoft's "Visual" people are having none of that!) so we end up with the icky "doPostback" routine.

  • User profile image
    candseeme

    mrichman wrote:
    Why is Firefox complaining with this error:

    ------------------------------------------------------------
    missing ) after argument list

    setTimeout('breakOut',5000);   
    ------------------------------------------------------------

    Here is the HTML that I'm producing:

    <html>
    <head>
    <script type="text/javascript">
    <!--
     function breakOut() {
     top.location.href = 'https://foo.com';
    }
    // -->
    </script>
    <body onLoad="setTimeout('breakOut()',5ØØØ);">
    You have been logged out of the control panel due to inactivity for your security.
    </body>
    </html>


    Remove those two and belive me
    Try it

  • User profile image
    W3bbo

    candseeme wrote:
    Remove those two and belive me
    Try it


    That wouldn't work.

    The ECMAScipt (colloquially known as "Javascript") specification requires all method calls to have parenthesis (like C#, this is to make it easy to differentiate between object Properties and Methods)

    Also the script interpreter error is specifically calling the line with the error.

  • User profile image
    candseeme

    W3bbo wrote:
    candseeme wrote: Remove those two and belive me
    Try it


    That wouldn't work.

    The ECMAScipt (colloquially known as "Javascript") specification requires all method calls to have parenthesis (like C#, this is to make it easy to differentiate between object Properties and Methods)

    Also the script interpreter error is specifically calling the line with the error.


    TRY IT BEFORE YOU CRY IT W3BBO

    Thanks

    Cool

  • User profile image
    W3bbo

    candseeme wrote:

    TRY IT BEFORE YOU CRY IT W3BBO

    Thanks

    Cool


    And have you tried it?

    What were the results?

  • User profile image
    candseeme

    W3bbo wrote:


    And have you tried it?

    What were the results?


    Yup i did i think it is your turn !

     

    Thanks

     

    Cool

  • User profile image
    PaintedBlue

    W3bbo wrote:
    candseeme wrote: Remove those two and belive me
    Try it


    That wouldn't work.

    The ECMAScipt (colloquially known as "Javascript") specification requires all method calls to have parenthesis (like C#, this is to make it easy to differentiate between object Properties and Methods)

    Also the script interpreter error is specifically calling the line with the error.


    In this case, it is not a method call. setTimeout's first argument should be a reference to a function, so the () should not be included.

  • User profile image
    W3bbo

    PaintedBlue wrote:
    W3bbo wrote:
    candseeme wrote: Remove those two and belive me
    Try it


    That wouldn't work.

    The ECMAScipt (colloquially known as "Javascript") specification requires all method calls to have parenthesis (like C#, this is to make it easy to differentiate between object Properties and Methods)

    Also the script interpreter error is specifically calling the line with the error.


    In this case, it is not a method call. setTimeout's first argument should be a reference to a function, so the () should not be included.


    Ah, my bad Smiley

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.