IE error using setTimeout and Select Tag in a frame.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Martin

    IE error using setTimeout and Select Tag in a frame.

    Hi,

    I've got a funny and wanted to know if there is a fix out there for
    this.

    I display a jsp inside a frame that monitors the database and reloads
    itself via the setTimeout js function. To improve functionality I
    added a dropdown where the user can select the frequency of reloading.

    The bug is this: Let the page reload by itself. Then click on the
    dropdown and do not select a value, just leave it open until the page
    reloads itself. You should get a blank page. Any ideas?

    ** test.jsp
    <%
    try {
    String MILLIS = request.getPara meter("mills");

    int millis = 15000;

    if (MILLIS != null && MILLIS.equals(" ") == false) {
    millis = Integer.parseIn t(MILLIS) * 1000;
    } else {
    MILLIS = "15";
    }

    System.out.prin tln("here...");
    System.out.prin tln("millis = " + millis);
    %>

    <html>
    <head>
    <title>Test</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="expires" CONTENT="0">
    <script>
    function reload()
    {
    setTimeout('doc ument.mon.submi t();', <%=millis%>);
    }
    reload();
    </script>
    </head>
    <body>
    <%=new java.util.Date( )%>
    <form name="mon" class="form" >
    Update this page every
    <select name="mills" onchange="javas cript:document. mon.submit();">
    <option value="7" <% if ("7".equals(MIL LIS)) { %>selected<% }
    %>>7 seconds</option>
    <option value="15" <% if ("15".equals(MI LLIS)) { %>selected<% }
    %>>15 seconds</option>
    <option value="30" <% if ("30".equals(MI LLIS)) { %>selected<% }
    %>>30 seconds</option>
    </select>
    </form>
    </body>
    </html>
    <%
    System.out.prin tln("here too...");

    } catch (Exception e) {
    System.out.prin tln("e.getMessa ge() = " + e.getMessage()) ;
    e.printStackTra ce();
    }
    %>
    ** end

    Thanks,
    Martin
  • Thomas 'PointedEars' Lahn

    #2
    Re: IE error using setTimeout and Select Tag in a frame.

    Martin wrote:
    [color=blue]
    > The bug is this: Let the page reload by itself. Then click on the
    > dropdown and do not select a value, just leave it open until the page
    > reloads itself. You should get a blank page. Any ideas?[/color]

    Don't post server-side script code, post what the client gets (see
    `view-source:$URI', Edit, View Source e.g.) instead. When you look
    at the generated code, you will most certainly find the error for
    yourself. Try `javascript:' in the Location Bar and enable the
    display of script errors in Internet Options, too.
    [color=blue]
    > onchange="javas cript:document. mon.submit();">[/color]

    `javascript:' URIs don't belong into event handlers. Within JavaScript
    code, `javascript:' is merely a label. If supported, it is ignored (since
    no statement refers to it.) If not supported, it results in a script error.
    (If the UA uses the label as an identifier for the script language to be
    used, it is b0rken since the default scripting language is defined with
    the `meta' element in the `head'.)

    And reference the form with the recommended (by
    W3C-DOM 2 HTML) document.forms['mon'] instead.


    PointedEars

    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: IE error using setTimeout and Select Tag in a frame.

      Thomas 'PointedEars' Lahn <PointedEars@we b.de> writes:

      [about onevent="javasc ript:..."]
      [color=blue]
      > (If the UA uses the label as an identifier for the script language to be
      > used, it is b0rken since the default scripting language is defined with
      > the `meta' element in the `head'.)[/color]

      However, there is no way to have a script in a language different from
      the default scripting language. That is probably why IE uses the label
      to specify the language (as pretty much the only widely used browser that
      supports more than one scripting langauge): You can have javascript
      and vbscript on the same page that way.

      I don't like it either, but given that there is no better alternative,
      I can understand why they do it.

      /L
      --
      Lasse Reichstein Nielsen - lrn@hotpop.com
      DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: IE error using setTimeout and Select Tag in a frame.

        Lasse Reichstein Nielsen wrote:
        [color=blue]
        > Thomas 'PointedEars' Lahn <PointedEars@we b.de> writes:
        > [about onevent="javasc ript:..."]
        >[color=green]
        >> (If the UA uses the label as an identifier for the script language to be
        >> used, it is b0rken since the default scripting language is defined with
        >> the `meta' element in the `head'.)[/color]
        >
        > However, there is no way to have a script in a language different from
        > the default scripting language.[/color]

        You're wrong. I have posted (IE-)working examples with VBScript and
        J(ava)Script here IIRC more than one time. Google is your friend. [psf 6.1]
        [color=blue]
        > That is probably why IE uses the label to specify the language (as pretty
        > much the only widely used browser that supports more than one scripting
        > langauge): You can have javascript and vbscript on the same page that way.[/color]

        You can have that without a proprietary interpretation of labels.
        [color=blue]
        > I don't like it either, but given that there is no better alternative,
        > I can understand why they do it.[/color]

        All scripts in a page share the same namespace, there is no need to define
        what language is meant unless there is a subroutine with the same identifier
        in languages different from the default scripting language. And if that, one
        can encapsulate that ambiguous statement in user-defined subroutines with
        different identifiers within `script' elements whose language is properly
        enough defined by the `language' and/or the `type' attribute.


        PointedEars

        Comment

        • Jim Ley

          #5
          Re: IE error using setTimeout and Select Tag in a frame.

          On Thu, 30 Oct 2003 21:10:40 +0100, Thomas 'PointedEars' Lahn
          <PointedEars@we b.de> wrote:
          [color=blue]
          >Lasse Reichstein Nielsen wrote:[color=green]
          >> However, there is no way to have a script in a language different from
          >> the default scripting language.[/color]
          >
          >You're wrong. I have posted (IE-)working examples with VBScript and
          >J(ava)Script here IIRC more than one time. Google is your friend. [psf 6.1][/color]

          Could you post a simple snippet which has different script languages
          used in intrinsic events without using the script label syntax?
          [color=blue]
          >All scripts in a page share the same namespace, there is no need to define
          >what language is meant unless there is a subroutine with the same identifier
          >in languages different from the default scripting language.[/color]

          I really don't understand this you're suggesting:

          onload="if (1==2) alert('a')"

          doesn't need to be told it's javascript because all scripts on the
          page share the same namespace?

          Jim.
          --
          comp.lang.javas cript FAQ - http://jibbering.com/faq/

          Comment

          • Lasse Reichstein Nielsen

            #6
            Re: IE error using setTimeout and Select Tag in a frame.

            Thomas 'PointedEars' Lahn <PointedEars@we b.de> writes:
            [color=blue]
            > You're wrong. I have posted (IE-)working examples with VBScript and
            > J(ava)Script here IIRC more than one time. Google is your friend. [psf 6.1][/color]

            You are probably referring to <news:3F96DA4F. 8020200@Pointed Ears.de>.

            It is correct that you can circumvent the problem by using only one
            language in the event handler attributes and using the other language
            in global functions that can be called cross-language.

            However, that still doesn't allow you to have JScript in one event
            attribute and VBScript in another. IE's label interpretation does.

            (Google did let me find "psf 6.1". Luckily, I can't seem to get it to
            store the cookie with my configuration. Otherwise I wouldn't have found
            a page in German :).
            [color=blue]
            > All scripts in a page share the same namespace, there is no need to define
            > what language is meant unless there is a subroutine with the same identifier
            > in languages different from the default scripting language. And if that, one
            > can encapsulate that ambiguous statement in user-defined subroutines with
            > different identifiers within `script' elements whose language is properly
            > enough defined by the `language' and/or the `type' attribute.[/color]

            That avoids the problem, but it doesn't solve it.

            /L
            --
            Lasse Reichstein Nielsen - lrn@hotpop.com
            DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
            'Faith without judgement merely degrades the spirit divine.'

            Comment

            • Thomas 'PointedEars' Lahn

              #7
              Re: IE error using setTimeout and Select Tag in a frame.

              Jim Ley wrote:
              [color=blue]
              > Thomas 'PointedEars' Lahn wrote:[color=green]
              >> Lasse Reichstein Nielsen wrote:[color=darkred]
              >>> However, there is no way to have a script in a language different
              >>> from the default scripting language.[/color]
              >>
              >> You're wrong. I have posted (IE-)working examples with VBScript and
              >> J(ava)Script here IIRC more than one time. Google is your friend.
              >> [psf 6.1][/color]
              >
              > Could you post a simple snippet which has different script languages
              > used in intrinsic events without using the script label syntax?[/color]

              As I wrote, I did it before:



              The `foobar()' JavaScript call can be as well placed in an
              event handler, provided that the default scripting language
              is JavaScript because it is the only scripting language the
              UA has a script engine for, or (better) because it is defined
              as the default scripting language (see below.)
              [color=blue][color=green]
              >> All scripts in a page share the same namespace, there is no need to
              >> define what language is meant unless there is a subroutine with the
              >> same identifier in languages different from the default scripting
              >> language.[/color]
              >
              > I really don't understand this you're suggesting:
              >
              > onload="if (1==2) alert('a')"
              >
              > doesn't need to be told it's javascript because all scripts on the
              > page share the same namespace?[/color]

              No, it is considered to be JavaScript because of

              <meta http-equiv="Content-Script-Type" content="text/javascript">

              within the `head' element as recommended by the HTML 4.01 Specification.

              The problem that can occur is that foobar() may be subroutine
              intrinsic to more than one supported scripting language, say
              FooScript and BarScript. Then you need to call that routine
              from a function of which the scripting language is known:

              <head>
              ...
              <meta http-equiv="Content-Script-Type" content="text/javascript">
              <script type="text/fooscript">
              func foo
              foobar{}
              cnuf
              </script>

              <script type="text/barscript">
              (bar)
              [
              foobar();
              ]
              </script>
              ...
              </head>
              <body>
              ...
              <... onwhatever="foo (); bar();" ...>
              ...
              </body>


              PointedEars
              --
              "Use any version of Microsoft Frontpage to create your site. (This won't
              prevent people from viewing your source, but no one will want to steal it.)"
              Tipp gegen Quellcode-Klau
              <http://www.vortex-webdesign.com/help/hidesource.htm>

              Comment

              • Jim Ley

                #8
                Re: IE error using setTimeout and Select Tag in a frame.

                On Fri, 31 Oct 2003 03:21:49 +0100, Thomas 'PointedEars' Lahn
                <PointedEars@we b.de> wrote:
                [color=blue]
                >Jim Ley wrote:[color=green][color=darkred]
                >>> You're wrong. I have posted (IE-)working examples with VBScript and
                >>> J(ava)Script here IIRC more than one time. Google is your friend.
                >>> [psf 6.1][/color]
                >>
                >> Could you post a simple snippet which has different script languages
                >> used in intrinsic events without using the script label syntax?[/color]
                >
                >As I wrote, I did it before:[/color]

                Please lookup the usage of "intrinsic events" it's from the HTML
                recommendation. Your example does not use different script languages
                in intrinsic events.
                [color=blue][color=green]
                >> onload="if (1==2) alert('a')"
                >>
                >> doesn't need to be told it's javascript because all scripts on the
                >> page share the same namespace?[/color]
                >
                >No[/color]

                So you are agreeing now with Lasse's original assertion, going back on
                your "you're wrong"

                |> However, there is no way to have a script in a language different from
                |> the default scripting language.
                |
                |You're wrong.
                [color=blue]
                >The problem that can occur is that foobar() may be subroutine
                >intrinsic to more than one supported scripting language, say
                >FooScript and BarScript.[/color]

                I didn't mention any function other than alert, that is not a problem
                (although your claim that all languages on a page share the same
                namespace is not actually sustainable, it's true to Windows IE, but
                there is no requirement that it be true.
                [color=blue]
                > <... onwhatever="foo (); bar();" ...>[/color]

                This relies on javascript (or whatever but a single language) Can you
                please provide an example which backs up your previous assertion that
                using the HTML 4 techniques does not limit you to one script language
                in your intrinsic events.

                The IE method of overriding the JScript label (perfectly legal to do
                so in ECMAScript btw.) seems like an elegant solution.

                Jim.
                --
                comp.lang.javas cript FAQ - http://jibbering.com/faq/

                Comment

                • Thomas 'PointedEars' Lahn

                  #9
                  Re: IE error using setTimeout and Select Tag in a frame.

                  Jim Ley wrote:
                  [color=blue]
                  > Thomas 'PointedEars' Lahn wrote:[color=green]
                  >> Jim Ley wrote:[color=darkred]
                  >>>> You're wrong. I have posted (IE-)working examples with VBScript
                  >>>> and J(ava)Script here IIRC more than one time. Google is your
                  >>>> friend. [psf 6.1]
                  >>>
                  >>> Could you post a simple snippet which has different script
                  >>> languages used in intrinsic events without using the script label
                  >>> syntax?[/color]
                  >>
                  >> As I wrote, I did it before:[/color]
                  >
                  > Please lookup the usage of "intrinsic events" it's from the HTML
                  > recommendation.[/color]

                  There's no need, I know what I'm writing about.
                  [color=blue]
                  > Your example does not use different script languages in intrinsic
                  > events.[/color]

                  I used subroutines from different script languages as I read you wanted
                  to see.
                  [color=blue][color=green][color=darkred]
                  >>> onload="if (1==2) alert('a')"
                  >>>
                  >>> doesn't need to be told it's javascript because all scripts on
                  >>> the page share the same namespace?[/color]
                  >>
                  >> No[/color]
                  >
                  > So you are agreeing now with Lasse's original assertion, going back
                  > on your "you're wrong"[/color]

                  You misunderstood what I wrote.
                  [color=blue]
                  > |> However, there is no way to have a script in a language
                  > |> different from the default scripting language.
                  > |
                  > | You're wrong.[/color]

                  Which is correct. We were talking about
                  scripts, not (intrinsic) event handlers.
                  [color=blue][color=green]
                  >> <... onwhatever="foo (); bar();" ...>[/color]
                  >
                  > This relies on javascript (or whatever but a single language)[/color]

                  Yes, of course. I did not dispute that.
                  [color=blue]
                  > The IE method of overriding the JScript label (perfectly legal to do
                  > so in ECMAScript btw.)[/color]

                  According to ECMAScript Editions 1 and 3, section 12.12 (Ed. 2 does not
                  mention labels):

                  | A Statement may be prefixed by a label. Labelled statements are only
                  | used in conjunction with labelled break and continue statements.
                  [color=blue]
                  > seems like an elegant solution.[/color]

                  It *seems*, yes.


                  PointedEars

                  Comment

                  Working...