SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Gone!
    Join Date
    Aug 2001
    Location
    Witty Location Parody
    Posts
    3,889
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Error trying to specify IFRAME as target for page

    Hi guys and girls,

    I'm having a problem with a simple function that I thought would work perfectly.

    I have a drop down menu using select boxes, and when the user selects one of the options, it passes the file name of requested page to a function and specifies an iFrame on the page as the target. But for some reason its not working.

    FORM (only included one of the select options)
    Code:
    <form name="europeform">
                <select name="europeselect" size="1" style="width:150px; font-size:11px; background-color: #ffffff;">
    <option value="london.htm" selected>London</option>
    </select><br>
    <input type="button" value="Submit" onClick="surfto(this.form)">
    </form>
    FUNCTION (in HEAD tags)
    Code:
    <script language="JavaScript">
    <!-- 
    
    function surfto(form) {
      var myindex=form.dest.selectedIndex
      window.open(form.dest.options[myindex].value, target="europe");
    }
    
    //-->
    
    </script>
    IFRAME
    Code:
    <IFRAME SRC="blank.htm" name="europe" frameborder="0"> 
                  <!-- Alternate content for non-supporting browsers -->
                  <table width="400" border="0" cellspacing="0" cellpadding="0" align="center">
                    <tr> 
                      <td> 
                        <div align="center"> 
                          <p><b>Your Browser does not support Inline frames.</b></p>
                          <p><b>Click <a href="../testlink.htm">here</a> for an alternative 
                            version of the page you requested.</b></p>
                        </div>
                      </td>
                    </tr>
                  </table>
    </IFRAME>
    Is the target="framename" not supported in using iFrames or have I just made a huge mistake that I have not picked up on.

    Thanks for any help on this guys,

    Cheers

    Glen

  2. #2
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont reall have time to give you some code, but this is whats wrong.

    this.form (try this.form.name and change form as the variable)

    ie

    PHP Code:
    <script language="JavaScript">
    <!-- 

    function 
    surfto(formName) {
      var 
    myindex=formName.dest.selectedIndex
      window
    .open(etarget="europe");
    }

    //-->

    </script> 
    dest is undefined as its not the same name as your select name change it to europeselect.

    no you cannot use

    target="europe"); like that

    instead of window.location

    change it to

    parent.frame_Name.location.href='blah.html'

    ps not a huge mistake, but lots of mistakes hehe

  3. #3
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    check here for a little example

    http://www.pageresource.com/jscript/jdrop3.htm

  4. #4
    Gone!
    Join Date
    Aug 2001
    Location
    Witty Location Parody
    Posts
    3,889
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers Andrew

    I didn't write the function as I can't really write custom js like that, but what you said made sense and the link should sort me out.

    Many thanks


Bookmarks

Posting Permissions

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