Javascript to change iframe url

thezone1

New Member
Messages
192
Reaction score
0
Points
0
Hi can anyone help me with this,
i currently have this line of code changing the url of a iframe,

The Javascript:
x = top.frames['menu'].location = "incl/menu.php";

The HTML:
<div id="menu">
<iframe id="menu" src="incl/menu.html" frameborder="0" allowtransparency="true"></iframe>
</div>


it is working in IE7, Safari, Opera but not in firefox ??

Any help guys thanks
 
Last edited:

woiwky

New Member
Messages
390
Reaction score
0
Points
0
Try it with a name attribute on the iframe. Like this:

Code:
<div id="menu">
  <iframe id="menu" name="menu" src="incl/menu.html" frameborder="0" allowtransparency="true"></iframe>
 </div>

Also, you shouldn't give two elements the same id in a page.
 
Last edited:

marshian

New Member
Messages
526
Reaction score
9
Points
0
(Very tired when writing this.)
Don't ever use the same id twice, either you rename the div or the iframe, it will help you a lot if you just keep in mind you must be able to know what object you're talking about.
And in your scripting, try
(if you'ld keep the iframe as "menu" and RENAME THE DIV)
Code:
document.getElementById("menu").src = "incl/menu.html";

Last remark: it's disencouraged to use frames...

I hope I could be of any help while I'm almost falling asleep,
Marshian
 
Top