...

View Full Version : Works in IE only?



Pembar
06-22-2009, 10:28 PM
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?



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



Thanks much,

Regards,
Pembar

Kor
06-23-2009, 10:07 AM
has your frame/iframe a name or an id? Can we see the HTML tag code of your frame / iframe?

Pembar
06-23-2009, 06:40 PM
Hey guys,

Here's a more complete example:

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

tomws
06-23-2009, 09:05 PM
Firebug throws an error on clicking:

document.frames is undefined

Pembar
06-23-2009, 09:31 PM
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

Pembar
06-23-2009, 09:34 PM
Nevermind.... I finally got it:



myFrame.src = url;

tomws
06-23-2009, 09:35 PM
Firebug. For Firefox. Quite useful.

Correct usage, according to here (http://www.sitepoint.com/forums/showthread.php?t=251907):

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().

Kor
06-24-2009, 10:11 AM
Try this


document.getElementById('myFrame').contentWindow.location.href =newurl;



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum