Change the src of an Iframe.

D

Defacta

Hi !

I have the HTML source like this:
<iframe name="Content_IF" name="Content_IF" border=0
width="200" height="200" src="iframe_login.php"></iframe>

And I tried to change the source of the iframe like this:
document.frames.Content_IF.location.href = 'iframe.php';
or like this:
document.Content_IF.location.href = 'iframe.php';

These 2 ways work with IE but none of them work with Firefox, how to
change the src of an iframe with Firefox ?

Thanks,
Vincent.
 
V

VK

Hi !

I have the HTML source like this:
<iframe name="Content_IF" name="Content_IF" border=0
width="200" height="200" src="iframe_login.php"></iframe>

And I tried to change the source of the iframe like this:
document.frames.Content_IF.location.href = 'iframe.php';
or like this:
document.Content_IF.location.href = 'iframe.php';

These 2 ways work with IE but none of them work with Firefox, how to
change the src of an iframe with Firefox ?

Document object has nothing to do with the task: though IE has
internal "wrong programming allowance fixes" for the most common
developers errors, like this one or say calling location.href(URL) as
a method. To be compatible with all UAs use the right way, do not
depend on IE's specific error correction mechanics:

self.frames['Content_IF'].src = newURL;
 
D

Defacta

I have the HTML source like this:
<iframe name="Content_IF" name="Content_IF" border=0
width="200" height="200" src="iframe_login.php"></iframe>
And I tried to change the source of the iframe like this:
document.frames.Content_IF.location.href = 'iframe.php';
or like this:
document.Content_IF.location.href = 'iframe.php';
These 2 ways work with IE but none of them work with Firefox, how to
change the src of an iframe with Firefox ?

Document object has nothing to do with the task: though IE has
internal "wrong programming allowance fixes" for the most common
developers errors, like this one or say calling location.href(URL) as
a method. To be compatible with all UAs use the right way, do not
depend on IE's specific error correction mechanics:

self.frames['Content_IF'].src = newURL;

Actually, the problem was in my HTML code, I had name="Content_IF"
instead of id="Content_IF"

Thanks,
Vincent.
 
T

Thomas 'PointedEars' Lahn

Defacta said:
I have the HTML source like this:
<iframe name="Content_IF" name="Content_IF" border=0
width="200" height="200" src="iframe_login.php"></iframe>
And I tried to change the source of the iframe like this:
document.frames.Content_IF.location.href = 'iframe.php';
or like this:
document.Content_IF.location.href = 'iframe.php';
These 2 ways work with IE but none of them work with Firefox, how to
change the src of an iframe with Firefox ?
Document object has nothing to do with the task: though IE has
internal "wrong programming allowance fixes" for the most common
developers errors, like this one or say calling location.href(URL) as
a method. To be compatible with all UAs use the right way, do not
depend on IE's specific error correction mechanics:

self.frames['Content_IF'].src = newURL;

Actually, the problem was in my HTML code, I had name="Content_IF"
instead of id="Content_IF"

Actually, this is one of these rare occasions where VK is almost right. If
you only change `name' to `id', your code will become even more unreliable
than it is now. Therefore, you should use the `name' attribute and the
proper collections instead:

window.frames['Content_IF'].location = newURL;


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top