/    Sign up×
Community /Pin to ProfileBookmark

document.iframe2.location.href=’racing.htm’;

iframe2 is a iframe in iframe1 and when i do

document.iframe2.location.href=’racing.htm’;

in iframe1 it only works in IE and not in firefox.

How do you do it in firefox so it still works in IE also ?

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@JonaJan 17.2005 — [font=trebuchet ms]Try...[/font]

<i>
</i>function yourFunction(){
if(!document.getElementById) return;
document.getElementById('iframe2').location.href = 'racing.htm';
}


[font=trebuchet ms]Be sure to give the IFrame an ID, too.[/font]

<i>
</i>id="iframe2"


[font=trebuchet ms]There may also be a way to refer to it as a frame, though I'm unsure (since I [i]rarely[/i] have a need for IFrames).[/font]

<i>
</i>top.frames[1].location.href = 'racing.htm';
Copy linkTweet thisAlerts:
@gert_cuykensauthorJan 17.2005 — firefox:

<IFRAME id="iframe2" name="iframe2" SRC="iframe2.htm" scrolling="no" frameborder="0"></IFRAME>

<span class=link onClick="document.iframe2.location.href='iframe2.htm';">about</span>

Error: document.iframe2 has no properties

<span class=link onClick="document.getElementById('iframe2').location.href='racing.htm';">racing</span>

Error: document.getElementById("iframe2").location has no properties
Copy linkTweet thisAlerts:
@JonaJan 17.2005 — [font=trebuchet ms]It's a window-object, so that's probably why it's not finding its ID. Did you see my edit and try it also?[/font]
Copy linkTweet thisAlerts:
@gert_cuykensauthorJan 17.2005 — top.frames[1].location.href = 'racing.htm';


Error: top.frames[1] has no properties
Copy linkTweet thisAlerts:
@PittimannJan 17.2005 — Hi!

Make sure, your iframes have [B]name [/B]attributes for this example:

top.frames['iframe1'].frames['iframe2'].location.href='racing.htm'

Cheers - Pit
Copy linkTweet thisAlerts:
@gert_cuykensauthorJan 17.2005 — top.frames['iframe1'].frames['iframe2'].location.href='racing.htm'

lol can you believe that this actualy works ?

thx
Copy linkTweet thisAlerts:
@PittimannJan 17.2005 — [i]Originally posted by gert cuykens [/i]

[B]top.frames['iframe1'].frames['iframe2'].location.href='racing.htm'



lol can you believe that this actualy works ?



thx [/B]
[/QUOTE]
It had to. The problems you were running into just derived from the fact that your iframes are "nested". I'm happy, that this simple line of code helped.

Cheers - Pit ?
×

Success!

Help @gert_cuykens spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...