Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need to block new history entry when opening link to targeted iframe

Status
Not open for further replies.

zeq

Technical User
Joined
May 22, 2006
Messages
1
Location
US
Hi everybody,
I have a page in an iframe whose links open up to another targeted iframe and I am trying to have the browser not put an entry in the history list when this happens, so when they click the back button it wont affect the new location of the targeted iframe.
I have tried several different things using location.replace() and history.previous but nothing seems to do exactly what I am looking for.

If this may help, the last thing that I tried that almost worked was putting this:
<body onunload="javascript:location.replace(this.href);">
on the html of the new page being loaded
it did not put any entries in history for the iframe, but you would have to click the link twice, and it would open the wrong page in between.

I also tried something like this on the links:
<a onclick="javascript:frames['mediaplayer'].location.replace('newlink.html');">
(mediaplayer is the name/id of the iframe the link are to open in)
but it was giving me an error saying it is not an object or is null

Hopefully someone can understand what I am saying and can give me a kick in the right direction.
If you need an example of the page I can put up links.
Thanks for any assistance, it is MUCH appreciated!
 
Try this:
Code:
<a onclick="document.frames['mediaplayer'].location.replace('newlink.html');">

If that doesn't do it, have a read of my post from March last year ("write to an iframe"): thread216-1021687 which shows you how to get a pointer to the iframe document in a more cross-browser way to see if that helps:

Code:
var ifrm = document.getElementById('myIframe');
ifrm = (ifrm.contentWindow) ? ifrm.contentWindow : (ifrm.contentDocument.document) ? ifrm.contentDocument.document : ifrm.contentDocument;
ifrm.location.replace('newlink.html');">

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top