469,910 Members | 1,486 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,910 developers. It's quick & easy.

Back button / iframe problem

Hi,

I have a directory with a file main.htm:

<html><body>
<p><iframe src=i.htm></iframe></p>
<p><a href="javascript:history.back()">Back</a></p>
</body></html>

and a file i.htm:

<html><body>
Content
</body></html>

The application can load main.htm in 5 different ways (always using
another frameset).

The 'Back' button should always affect main.htm (never i.htm). But I
cannot find a way to make this work, unless I start hardcoding on the
frame names/DOM themselves. But I want to avoid that, because the
applicability of main.htm must be ensured in all kind of (future)
framesets, and I don't want to modify main.htm every time for each new
frameset. Also, I can not rely on the frame name that main.htm might
(or might not) get from a parent.

I tried things like

self.history.back
window.history.back
...

but they go to the previous page of i.htm, not that of main.htm (unless
i.htm is "out of previous pages", so to say, then it goes to the
previous page of main.htm).

Any workarounds ?

Thanks,

--
Bart

Dec 14 '05 #1
2 9594
Bart Van der Donck said the following on 12/14/2005 3:22 PM:
Hi,

I have a directory with a file main.htm:

<html><body>
<p><iframe src=i.htm></iframe></p>
<p><a href="javascript:history.back()">Back</a></p>
</body></html>

and a file i.htm:

<html><body>
Content
</body></html>

The application can load main.htm in 5 different ways (always using
another frameset).

The 'Back' button should always affect main.htm (never i.htm). But I
cannot find a way to make this work, unless I start hardcoding on the
frame names/DOM themselves. But I want to avoid that, because the
applicability of main.htm must be ensured in all kind of (future)
framesets, and I don't want to modify main.htm every time for each new
frameset. Also, I can not rely on the frame name that main.htm might
(or might not) get from a parent.

I tried things like

self.history.back
window.history.back


parent.history.back();

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 14 '05 #2
Randy Webb writes:
Bart Van der Donck said the following on 12/14/2005 3:22 PM:
I have a directory with a file main.htm:

<html><body>
<p><iframe src=i.htm></iframe></p>
<p><a href="javascript:history.back()">Back</a></p>
</body></html>

and a file i.htm:

<html><body>
Content
</body></html>

The application can load main.htm in 5 different ways (always using
another frameset).

The 'Back' button should always affect main.htm (never i.htm). But I
cannot find a way to make this work, unless I start hardcoding on the
frame names/DOM themselves. But I want to avoid that, because the
applicability of main.htm must be ensured in all kind of (future)
framesets, and I don't want to modify main.htm every time for each new
frameset. Also, I can not rely on the frame name that main.htm might
(or might not) get from a parent.

parent.history.back();


My tests show the following results for your suggestion (XP IE6):

1. If main.htm is in a frameset:

parent.history.back() goes to the previous page of main.htm's parent
(not to the previous page of main.htm itself). So just history.back()
would be better than parent.history.back(), because history.back()
affects by default the document from which it was invoked ("self").
Also, the surrounding frameset is mostly from another domain name, so I
get a js error.

2. If main.htm is not in a frameset:

Same behaviour as history.back()

Thanks again

--
Bart

Dec 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Nick Tew | last post: by
4 posts views Thread by PiedmontBiz | last post: by
8 posts views Thread by Rose Chambers | last post: by
1 post views Thread by Johan Nedin | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.