Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jun 2009
    Posts
    44
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Works in IE only?

    Hey guys,

    I have the following code which seems to only work in IE. I tried all the different combinations in FF but can't seem to get it to work, does anyone know the FF equivalent? Or is it something unique to IE?

    Code:
    document.frames['myFrame'].location.href = xmlhttp2.responseText

    Thanks much,

    Regards,
    Pembar

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    has your frame/iframe a name or an id? Can we see the HTML tag code of your frame / iframe?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New Coder
    Join Date
    Jun 2009
    Posts
    44
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Hey guys,

    Here's a more complete example:

    Code:

    Code:
    <html>
    <body>
    <script language="JavaScript">
    function myLocation() {
    alert(document.all.myFrame.contentWindow.location);
    }
    function changeURL(url) {
    document.getElementById("urlAddress1").value=url;
    document.frames['myFrame'].location.href = url;
    
    }
    </script>
    <iframe id="myFrame" src="http://www.google.com" style="width:200;">
    </iframe>
    <br>
    <button onclick="changeURL('http://www.yahoo.com');">Yahoo</button><P>
    		1. <input type="button" name="clickMe2" id="urlAddress1" value="CurrentURL"/><P>
    </body>
    </html>
    It works fine in IE when I click "Yahoo", the frame changes. When I click "Yahoo" in FF, nothing happens.

    Any clue?

    Thanks much.

    Regards,
    Pembar

  • #4
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Firebug throws an error on clicking:
    document.frames is undefined
    Are you a Help Vampire?

  • #5
    New Coder
    Join Date
    Jun 2009
    Posts
    44
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by tomws View Post
    Firebug throws an error on clicking:

    Quick question: which tool are you using to detect this?

    And if you have time, can you suggest the proper code? I've tried the following but nothing seems to work:

    parent.myFrame.location.href = url;
    parent.document.getElementById('myFrame').
    document.myFrame.location.href

    Regards,
    Pembar

  • #6
    New Coder
    Join Date
    Jun 2009
    Posts
    44
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Nevermind.... I finally got it:

    Code:
    myFrame.src = url;

  • #7
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Firebug. For Firefox. Quite useful.

    Correct usage, according to here:
    The use of frames[] to address an array of iframe objects is IE-only. You can give your single iframe an id, then use getElementById(), or you can create your own array of iframe elements with getElementsByTagName().
    Are you a Help Vampire?

  • #8
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Try this
    Code:
    document.getElementById('myFrame').contentWindow.location.href =newurl;
    Last edited by Kor; 06-24-2009 at 11:14 AM.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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