Make an iframe go back?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
toasty2
Forum Contributor
Posts: 361
Joined: Wed Aug 03, 2005 10:28 am
Location: Arkansas, USA

Make an iframe go back?

Post by toasty2 »

I'm trying to get an iframe (and not the whole webpage) to go back, like history(-1). Everything I've tried hasn't worked. Could someone show me a working example?
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

window.frames['frameName'].history(-1) I believe... though untested
toasty2
Forum Contributor
Posts: 361
Joined: Wed Aug 03, 2005 10:28 am
Location: Arkansas, USA

Post by toasty2 »

It doesn't work :(

I also tried using window.frames.frameName.history(-1). (frameName being the frame of course)
toasty2
Forum Contributor
Posts: 361
Joined: Wed Aug 03, 2005 10:28 am
Location: Arkansas, USA

Post by toasty2 »

I'll give some more details.

I have an iframe with a name and id of "o". The following things don't work:

Code: Select all

<a href="#" onclick="window.frames.o.history.go(-1);">back</a>
<a href="#" onclick="window.frames.o.history.back();">back</a>
<a href="#" onclick="window.frames['o'].history.back();">back</a>
Am I doing it wrong?
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

how about something along the lines of

Code: Select all

document.getElementsByTagName('IFRAME')[0].history.go(-1);
toasty2
Forum Contributor
Posts: 361
Joined: Wed Aug 03, 2005 10:28 am
Location: Arkansas, USA

Post by toasty2 »

Doesn't work. Why don't any of these work? A website even used two of those as examples!
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

OK try:

document.getElementsByTagName('IFRAME')[0].history.back();
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

Code: Select all

parent.frames[0].history.back()
works in FF but not in IE - IE seems to deny you control of the frame if it's containing info from another domain :-(
toasty2
Forum Contributor
Posts: 361
Joined: Wed Aug 03, 2005 10:28 am
Location: Arkansas, USA

Post by toasty2 »

At least it works at all. I use Firefox, so that'll work (this is for my own personal website...I'm not insanely concerned about IE)
Post Reply