JS code inside frameset..

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Frances Del Rio

    #1

    JS code inside frameset..


    can u put JS code inside a frameset? I have this, and it's not working,
    even test alerts are ignored, in both browsers.. thank you..
    Frances Del Rio


    <frameset rows="90,*" border=0 frameborder="0" framespacing="0 ">
    <frame name="header" src="header.htm l" scrolling="no" frameborder="0" >
    <script language="Javas cript">
    if(navigator.ap pName == "Netscape") {
    alert('ha')
    document.write( "<frameset cols='120,*' frameborder='0' framespacing='0 '>")
    }
    else {
    alert('ha')
    document.write( "<frameset cols='112,*' frameborder='0' framespacing='0 '>")
    }
    </script>

    <frame name="nav" src="menu.html" scrolling="no" frameborder="0" >
    <frame name="main" src="check_puid .jsp" scrolling="auto " frameborder="0" >
    </frameset>

  • Ron

    #2
    Re: JS code inside frameset..

    Frances Del Rio wrote:
    [color=blue]
    >
    > can u put JS code inside a frameset? I have this, and it's not
    > working, even test alerts are ignored, in both browsers.. thank you..
    > Frances Del Rio
    >
    >
    > <frameset rows="90,*" border=0 frameborder="0" framespacing="0 ">
    > <frame name="header" src="header.htm l" scrolling="no" frameborder="0" >
    > <script language="Javas cript">
    > if(navigator.ap pName == "Netscape") {
    > alert('ha')
    > document.write( "<frameset cols='120,*' frameborder='0'
    > framespacing='0 '>")
    > }
    > else {
    > alert('ha')
    > document.write( "<frameset cols='112,*' frameborder='0'
    > framespacing='0 '>")
    > }
    > </script>
    >
    > <frame name="nav" src="menu.html" scrolling="no" frameborder="0" >
    > <frame name="main" src="check_puid .jsp" scrolling="auto " frameborder="0" >
    > </frameset>
    >[/color]
    script elements are not allowed in frameset elements ->
    http://www.w3.org/TR/html401/present....html#h-16.2.1 . Put your
    script in the head element instead.

    Comment

    • Frances Del Rio

      #3
      Re: JS code inside frameset..

      bummer........
      [color=blue]
      > script elements are not allowed in frameset elements ->
      > http://www.w3.org/TR/html401/present....html#h-16.2.1 . Put your
      > script in the head element instead.[/color]

      well, that's not of much use to me.. I need one frame with for Netscape
      (N 4.7, I'm talking, hence the problem..) and another width for same
      frame in IE.. thank you yr response.. Frances

      [color=blue]
      > Frances Del Rio wrote:
      >[color=green]
      >>
      >> can u put JS code inside a frameset? I have this, and it's not
      >> working, even test alerts are ignored, in both browsers.. thank you..
      >> Frances Del Rio
      >>
      >>
      >> <frameset rows="90,*" border=0 frameborder="0" framespacing="0 ">
      >> <frame name="header" src="header.htm l" scrolling="no" frameborder="0" >
      >> <script language="Javas cript">
      >> if(navigator.ap pName == "Netscape") {
      >> alert('ha')
      >> document.write( "<frameset cols='120,*' frameborder='0'
      >> framespacing='0 '>")
      >> }
      >> else {
      >> alert('ha')
      >> document.write( "<frameset cols='112,*' frameborder='0'
      >> framespacing='0 '>")
      >> }
      >> </script>
      >> <frame name="nav" src="menu.html" scrolling="no" frameborder="0" >
      >> <frame name="main" src="check_puid .jsp" scrolling="auto " frameborder="0" >
      >> </frameset>
      >>[/color][/color]

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: JS code inside frameset..

        Frances Del Rio wrote:
        [color=blue]
        > bummer........[/color]

        ?
        [color=blue][color=green]
        > > script elements are not allowed in frameset elements ->
        > > http://www.w3.org/TR/html401/present....html#h-16.2.1 . Put your
        > > script in the head element instead.[/color]
        >
        > well, that's not of much use to me..[/color]

        It is. Since you cannot use the "script" element within the "frameset"
        element, but you *can* use it within the "head" element, you should do so.
        See <40A5890A.40409 04@PointedEars. de>.
        [color=blue]
        > [Top post][/color]

        Please take heed of <http://jibbering.com/faq/#FAQ2_3>.


        PointedEars

        Comment

        • Lee

          #5
          Re: JS code inside frameset..

          Frances Del Rio said:[color=blue]
          >
          >bummer...... ..
          >[color=green]
          > > script elements are not allowed in frameset elements ->
          > > http://www.w3.org/TR/html401/present....html#h-16.2.1 . Put your
          > > script in the head element instead.[/color]
          >
          >well, that's not of much use to me.. I need one frame with for Netscape
          >(N 4.7, I'm talking, hence the problem..) and another width for same
          >frame in IE.. thank you yr response.. Frances[/color]

          Tested in Netscape 7 and IE6:

          <html>
          <head>
          <script type="text/javascript">
          var cols=(navigator .appName == "Netscape")?120 :112;
          var html=[
          '<frameset rows="90,*" border=0 frameborder="0" framespacing="0 ">',
          '<frame name="header" src="header.htm l" scrolling="no" frameborder="0" >',
          "<frameset cols='"+cols+", *' frameborder='0' framespacing='0 '>",
          '<frame name="nav" src="menu.html" scrolling="no" frameborder="0" >',
          '<frame name="main" src="check_puid .jsp" scrolling="auto " frameborder="0" >',
          '</frameset></frameset>'
          ];
          document.write( html.join(""));
          </script>
          </head>
          </html>

          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: JS code inside frameset..

            Lee wrote:
            [color=blue]
            > var cols=(navigator .appName == "Netscape")?120 :112;
            > var html=[
            > '<frameset rows="90,*" border=0 frameborder="0" framespacing="0 ">',
            > '<frame name="header" src="header.htm l" scrolling="no" frameborder="0" >',
            > "<frameset cols='"+cols+", *' frameborder='0' framespacing='0 '>",
            > '<frame name="nav" src="menu.html" scrolling="no" frameborder="0" >',
            > '<frame name="main" src="check_puid .jsp" scrolling="auto " frameborder="0" >',
            > '</frameset></frameset>'
            > ];
            > document.write( html.join(""));[/color]

            Nice one. But as for legibility of the resulting code, one should rather use

            document.write( html.join("\n") );

            And note that Array object initializers are not supported by all script
            engines, so you may want to use

            var html = new Array(
            ...
            );

            as well. However, browser sniffing does not work:

            <http://pointedears.de/scripts/test/whatami>


            PointedEars

            Comment

            • Jim Ley

              #7
              Re: JS code inside frameset..

              On Fri, 28 May 2004 23:31:21 +0200, Thomas 'PointedEars' Lahn
              <PointedEars@nu rfuerspam.de> wrote:
              [color=blue]
              >Nice one. But as for legibility of the resulting code, one should rather use
              >
              > document.write( html.join("\n") );[/color]

              I'd recommend "" - the fewer redundant nodes you have in the DOM the
              better - why would you be reading generated code anyway?

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

              Comment

              • Lee

                #8
                Re: JS code inside frameset..

                Thomas 'PointedEars' Lahn said:[color=blue]
                >
                >Lee wrote:
                >[color=green]
                >> var cols=(navigator .appName == "Netscape")?120 :112;
                >> var html=[
                >> '<frameset rows="90,*" border=0 frameborder="0" framespacing="0 ">',
                >> '<frame name="header" src="header.htm l" scrolling="no" frameborder="0" >',
                >> "<frameset cols='"+cols+", *' frameborder='0' framespacing='0 '>",
                >> '<frame name="nav" src="menu.html" scrolling="no" frameborder="0" >',
                >>'<frame name="main" src="check_puid .jsp" scrolling="auto " frameborder="0" >',
                >> '</frameset></frameset>'
                >> ];
                >> document.write( html.join(""));[/color]
                >
                >Nice one. But as for legibility of the resulting code, one should rather use
                >
                > document.write( html.join("\n") );
                >
                >And note that Array object initializers are not supported by all script
                >engines, so you may want to use
                >
                > var html = new Array(
                > ...
                > );
                >
                >as well. However, browser sniffing does not work:[/color]


                1. During testing, I did join a newline, and alerted the result.
                I changed it to "" and deleted the alert for release.

                2. This is probably the first time I've used browser sniffing,
                and did so only because the OP's requirement was to have a
                different frame size in Netscape, specifically. Personally,
                I would try to avoid such a requirement.

                Comment

                • Thomas 'PointedEars' Lahn

                  #9
                  Re: JS code inside frameset..

                  Jim Ley wrote:
                  [color=blue]
                  > [...] Thomas 'PointedEars' Lahn [...] wrote:[color=green]
                  >> Nice one. But as for legibility of the resulting code, one should
                  >> rather use
                  >>
                  >> document.write( html.join("\n") );[/color]
                  >
                  > I'd recommend "" - the fewer redundant nodes you have in the DOM the
                  > better -[/color]

                  Generally, agreed. But it is unlikely that someone
                  will access the top frameset element with the DOM.
                  [color=blue]
                  > why would you be reading generated code anyway?[/color]

                  To see that it worked.


                  PointedEars

                  Comment

                  Working...