JavaScript Franes Select Problems

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jascraig@gmail.com

    #1

    JavaScript Franes Select Problems

    Here's my dilemma. I'm working with a frameset with 3 frames
    (header,content ,control). My control frame contains a select list with
    buttons for next and previous. When the next button is pushed the
    select list moves to the next option and the content frame changes to
    the next URL, and a page number is updated on the header. The code I
    have now works great on NS 7 and FF1. When I test it in IE, the select
    box updates then immediately resets to index 0. Has anyone come upon
    this.
    Thanks,

    Jason

    Code follows:

    Default Frameset:

    function next(obj){
    // Handle Next button event
    var cnt = obj.pages.selec tedIndex;
    // If within the range of pages specified on the drop-down options
    list,go to next page.
    if(cnt < obj.pages.lengt h-1){
    cnt=eval(cnt+1) ;
    obj.pages.selec tedIndex=cnt;
    content.locatio n.href=control. url_list[cnt];
    header.swapText (cnt+1);
    alert(cnt);
    }
    // Else go to first page of next topic UNLESS the current topic is last
    topic, in that case, alert user.
    else {
    alert("This is the last page of the topic area.");
    }
    }
    // - End of Control Pad Script -->
    </script>
    </head>
    <frameset rows = "115,*" cols = "*" border = "0">
    <noframes>
    <body><p>This topic requires a 4.0 browser with frames.</p></body>
    </noframes>
    <frame name = "header" src = "asdf_header.ht m" scrolling="no"
    frameborder = "0" />
    <frameset name = "lower" rows = "*,30" cols = "*" border = "0">
    <frame src = "asdf_01.ht m" name = "content" frameborder = "0" />
    <frame src = "asdf_control.h tm" name = "control" scrolling = "NO"
    frameborder = "0" marginwidth = "0" marginheight = "1" />
    </frameset>

    Control Page:

    <body bgcolor="#CCCCC C"
    onload="parent. header.setIniti alPages(1,url_l ist.length);">
    <form id="control_pad " action="" name="control_p ad">
    <center>
    <table border="0" cellspacing="0" cellpadding="0" bgcolor="#CCCCC C">
    <tr valign="top" align="left">
    <td height="27" width="62"><a href="#" onMouseOut="MM_ swapImgRestore( )"
    onMouseOver="MM _swapImage('Exi t','','../../u_images/exitOver.gif',1 )"><input
    type = "image" src="../../u_images/exit.gif" alt="Exit" name="Exit"
    width="62" height="27" border="0" onclick="top.wi ndow.closeWindo w()"
    /></a></td>
    <td height="27" width="110"><a href="#"
    onMouseOut="MM_ swapImgRestore( )"
    onMouseOver="MM _swapImage('Fee dback','','../../u_images/fbOver.gif',1)" ><input
    type = "image" src="../../u_images/fb.gif" alt="Feedback"
    name="Feedback" width="110" height="27" border="0"
    onclick="openFe edback()"></a></td>
    <td height="27" width="107"><a href="#"
    onMouseOut="MM_ swapImgRestore( )"
    onMouseOver="MM _swapImage('Glo ssary','','../../u_images/glossOver.gif', 1)"><input
    type="image" src="../../u_images/gloss.gif" alt="Glossary"
    name="Glossary" width="107" height="27" border="0"
    onclick="openGl ossary()"></a></td>
    <td height="25" width="200" bgcolor="#00009 9">
    <select name="pages" size="1" onchange="go_to (this.form)">
    <option value="asdf_01. htm">Introducti on</option>
    <option value="asdf_02. htm">Page 1</option>
    <option value="asdf_03. htm">Page 2</option>
    <option value="asdf_04. htm">Page 3</option>
    <option value="asdf_05. htm">Page 4</option>
    <option value="asdf_06. htm">Page 5</option>
    <option value="asdf_n.h tm">Summary</option>
    </select>
    </td>
    <td height="27" width="111"><a href="#"
    onMouseOut="MM_ swapImgRestore( )"
    onMouseOver="MM _swapImage('Men u','','../../u_images/menuOver.gif',1 )"><input
    type = "image" name = "Menu" src="../../u_images/menu.gif" onclick =
    "openMenu() " width="111" height="27"></input></a></td>
    <td height="27" width="80"><a href="#"><input type = "image" name =
    "Back" src="../../u_images/back.gif" onclick = "prev(this.form )"
    onMouseOut="MM_ swapImgRestore( )"
    onMouseOver="MM _swapImage('Bac k','','../../u_images/backOver.gif',1 )"
    width="80" height"></a></input></td>
    <td height="27" width="83"><a href="javascrip t:next(this.for m)"
    onMouseOut="MM_ swapImgRestore( )"
    onMouseOver="MM _swapImage('For ward','','../../u_images/forwardOver.gif ',1)"><input
    type = "image" name ="Forward" src = "../../u_images/forward.gif"
    width="83" height="27"></input></a></td>
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>

  • RobB

    #2
    Re: JavaScript Franes Select Problems

    jascraig@gmail. com wrote:[color=blue]
    > Here's my dilemma. I'm working with a frameset with 3 frames
    > (header,content ,control). My control frame contains a select list[/color]
    with[color=blue]
    > buttons for next and previous. When the next button is pushed the
    > select list moves to the next option and the content frame changes to
    > the next URL, and a page number is updated on the header. The code I
    > have now works great on NS 7 and FF1. When I test it in IE, the[/color]
    select[color=blue]
    > box updates then immediately resets to index 0. Has anyone come upon
    > this.
    > Thanks,
    >
    > Jason
    >
    > Code follows:
    >
    > Default Frameset:
    >
    > function next(obj){
    > // Handle Next button event
    > var cnt = obj.pages.selec tedIndex;
    > // If within the range of pages specified on the drop-down options
    > list,go to next page.
    > if(cnt < obj.pages.lengt h-1){
    > cnt=eval(cnt+1) ;
    > obj.pages.selec tedIndex=cnt;
    > content.locatio n.href=control. url_list[cnt];
    > header.swapText (cnt+1);
    > alert(cnt);
    > }
    > // Else go to first page of next topic UNLESS the current topic is[/color]
    last[color=blue]
    > topic, in that case, alert user.
    > else {
    > alert("This is the last page of the topic area.");
    > }
    > }
    > // - End of Control Pad Script -->
    > </script>
    > </head>
    > <frameset rows = "115,*" cols = "*" border = "0">
    > <noframes>
    > <body><p>This topic requires a 4.0 browser with frames.</p></body>
    > </noframes>
    > <frame name = "header" src = "asdf_header.ht m" scrolling="no"
    > frameborder = "0" />
    > <frameset name = "lower" rows = "*,30" cols = "*" border = "0">
    > <frame src = "asdf_01.ht m" name = "content" frameborder = "0" />
    > <frame src = "asdf_control.h tm" name = "control" scrolling = "NO"
    > frameborder = "0" marginwidth = "0" marginheight = "1" />
    > </frameset>
    >
    > Control Page:
    >
    > <body bgcolor="#CCCCC C"
    > onload="parent. header.setIniti alPages(1,url_l ist.length);">
    > <form id="control_pad " action="" name="control_p ad">
    > <center>
    > <table border="0" cellspacing="0" cellpadding="0" bgcolor="#CCCCC C">
    > <tr valign="top" align="left">
    > <td height="27" width="62"><a href="#"[/color]
    onMouseOut="MM_ swapImgRestore( )"[color=blue]
    >[/color]
    onMouseOver="MM _swapImage('Exi t','','../../u_images/exitOver.gif',1 )"><input[color=blue]
    > type = "image" src="../../u_images/exit.gif" alt="Exit" name="Exit"
    > width="62" height="27" border="0" onclick="top.wi ndow.closeWindo w()"
    > /></a></td>
    > <td height="27" width="110"><a href="#"
    > onMouseOut="MM_ swapImgRestore( )"
    >[/color]
    onMouseOver="MM _swapImage('Fee dback','','../../u_images/fbOver.gif',1)" ><input[color=blue]
    > type = "image" src="../../u_images/fb.gif" alt="Feedback"
    > name="Feedback" width="110" height="27" border="0"
    > onclick="openFe edback()"></a></td>
    > <td height="27" width="107"><a href="#"
    > onMouseOut="MM_ swapImgRestore( )"
    >[/color]
    onMouseOver="MM _swapImage('Glo ssary','','../../u_images/glossOver.gif', 1)"><input[color=blue]
    > type="image" src="../../u_images/gloss.gif" alt="Glossary"
    > name="Glossary" width="107" height="27" border="0"
    > onclick="openGl ossary()"></a></td>
    > <td height="25" width="200" bgcolor="#00009 9">
    > <select name="pages" size="1" onchange="go_to (this.form)">
    > <option value="asdf_01. htm">Introducti on</option>
    > <option value="asdf_02. htm">Page 1</option>
    > <option value="asdf_03. htm">Page 2</option>
    > <option value="asdf_04. htm">Page 3</option>
    > <option value="asdf_05. htm">Page 4</option>
    > <option value="asdf_06. htm">Page 5</option>
    > <option value="asdf_n.h tm">Summary</option>
    > </select>
    > </td>
    > <td height="27" width="111"><a href="#"
    > onMouseOut="MM_ swapImgRestore( )"
    >[/color]
    onMouseOver="MM _swapImage('Men u','','../../u_images/menuOver.gif',1 )"><input[color=blue]
    > type = "image" name = "Menu" src="../../u_images/menu.gif" onclick =
    > "openMenu() " width="111" height="27"></input></a></td>
    > <td height="27" width="80"><a href="#"><input type = "image" name=
    > "Back" src="../../u_images/back.gif" onclick = "prev(this.form )"
    > onMouseOut="MM_ swapImgRestore( )"
    > onMouseOver="MM _swapImage('Bac k','','../../u_images/backOver.gif',1 )"
    > width="80" height"></a></input></td>
    > <td height="27" width="83"><a href="javascrip t:next(this.for m)"
    > onMouseOut="MM_ swapImgRestore( )"
    >[/color]
    onMouseOver="MM _swapImage('For ward','','../../u_images/forwardOver.gif ',1)"><input[color=blue]
    > type = "image" name ="Forward" src = "../../u_images/forward.gif"
    > width="83" height="27"></input></a></td>
    > </td>
    > </tr>
    > </table>
    > </form>
    > </body>
    > </html>[/color]

    Surprised that it works anywhere, as you've referenced 'this.form'
    within that link's href (<a href="javascrip t:next(this.for m)"..). As JS
    urls execute with global scope and there (presumably) is no global
    'form' property it should fail. iirc it's IE that applies a form's
    scope chain to non-form elements nested inside a form. Whatever. The
    reset of the listbox is probably a result of the (re-)loading of the
    page as a side effect of that link. Try:

    <td height="27" width="83"><a href="#" onclick="return
    next(document.c ontrol_pad)"...

    ....and add 'return false;' to your next() function.

    <input> is a singlet tag, no closing </input>.

    Pointless: cnt=eval(cnt+1) ;

    Comment

    • jascraig@gmail.com

      #3
      Re: JavaScript Franes Select Problems

      That's the fix. Thanks. I was modifying outdated code, and I'm a Java
      guy, not JavaScript.

      Appreciate it.

      Comment

      Working...