Results 1 to 3 of 3

Thread: frame problem

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2002
    Posts
    56

    frame problem

    I have a problem with frames. I made a file called mainframes.html which is an empty HTML file. I have another file called buttonframe.html (the code at the end). The third file is called qwert.html and looks as follows:
    <html>
    <head>
    <frameset rows="7%,93%">
    <frame src="buttonframe.html">
    <frame src="mainframe.html">
    </frameset>
    <title>probeer</title>
    </head>
    <body>
    </body>
    </html>

    The button frame contains a dropdownbox with several links in it. If I click such a link then the output has to appear in mainframe.html. The code of buttonframe.html is given below. The function of the script is that if you change the value into the dropdownbox then one of the six links (to.html, mar.html,mam.html, om.html,bes.html and sj.html) will be loaded.

    My question is what do I have to change if I want the new page to be loaded in mainframe.html ?
    It is probably very simple but I am not that good in HTML and javascript.

    <HTML>
    <HEAD>
    <script language="JavaScript">

    function doArray() {
    var arylnth = doArray.arguments.length;
    for ( i = 0 ; i < arylnth ; i++ ) { this[i]=doArray.arguments[i] } }

    function newpage() {
    var choose = eval(document.dropdown.site.selectedIndex); if( (choose > 0) && (choose <
    12) ) {
    var section=new doArray( '',
    'to.html',
    'mar.html',
    'mam.html',
    'om.html',
    'bes.html',
    'sj.html');
    location=section[document.dropdown.site.selectedIndex];
    }
    }

    </script>
    <TITLE></TITLE>
    </HEAD>
    <BODY>
    <form name="dropdown" target="mainframe">
    <p><select name="site" size="1" onchange="newpage();"
    align="left">
    <option selected>Afdeling.... </option>
    <option>Tot</option>
    <option>Mar</option>
    <option>Mam</option>
    <option>Om</option>
    <option>Bes</option>
    <option>Sj</option>
    </select> </p>
    </form>
    </BODY>
    </HTML>

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    VB Code:
    1. top.frames[1].location = section[document.dropdown.site.selectedIndex];

    I think that will work

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Addicted Member
    Join Date
    Nov 2001
    Location
    Yewston, Texis
    Posts
    240
    Just some corrections, Frames don't have <body>'s and the frameset information doesn't belong in the <head> clause, so here's what your code should look like:

    <html>
    <head>
    <title>probeer</title>
    </head>
    <frameset rows="7%,93%">
    <frame src="buttonframe.html">
    <frame src="mainframe.html">
    </frameset>
    </html>

    Another thing, in your frame, this line will work OK as you already have it:
    <frame src="buttonframe.html">

    However, what would be better would be:
    <frame src="buttonframe.html" name="buttonframe">

    In this instance, giving the frame a name, gives you more flexibility to add other frames later without having to change your references from, say, top.frames[1].location to top.frames[2].location

    So crptcblade's code would then become:

    top.buttonframe.location = section[document.dropdown.site.selectedIndex];

    I recommend giving all your frames names in case you need to target them. It also helps to document what the frames' functions are.

    cudabean

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width