views:

136

answers:

2

Hi everyone,

I'm trying to create a widget (which is basically an iframe) that would have its own back and forward buttons. That is, when I hit the widget back-button, only the iframe goes back, not the entire widget container (the iGoogle-like portal)

I added the following links:

<a class="button" href="#" onclick="history.back();return false;">

It works when I load my widget as a regular webpage, but not when it is used from within the iframe.

I googled a little bit to find this post:

http://www.bennadel.com/blog/1592-Getting-IFRAME-Window-And-Then-Document-References-With-contentWindow.htm

Maybe there is something to do with that contentWindow attribute, but so far nothing. The issue is that I can't get the name of the frame that is used by the portal (which is random anyway)

I feel like I'm missing something... any hints?

Thanks!

A: 

Try this:

<a class="button" href="#" onclick="parent.history.back();return false;">
Rui Carneiro
Hi, thanks for your help!Unfortunately, I can't access parent.* because the portal and my widget aren't located under the same domain.And, even if they were, wouldn't parent.history.back() just make the main page go back? (instead of just my frame?)Thanks!
Pedro
After some tests i found that my code don't work. Iframes write on parents history :\
Rui Carneiro
Alright, thanks for you help!
Pedro
+1  A: 

Since your widget and the page are hosted under different domains for sequre reasons you won't get access from iframe to the parent page by scripts.

fantactuka
Alright, that's what I pretty much figured out...Guess I'll have to give up on that for now :/Thanks!
Pedro