开发者

How to hide the iFrame URL on the address bar when linking within the iFrame?

开发者 https://www.devze.com 2023-02-06 02:24 出处:网络
We have this iFrame inside our homepage which shows content from another website. And there are links within this iFrame. What happens is, when we click on the link, the content shows within the iFram

We have this iFrame inside our homepage which shows content from another website. And there are links within this iFrame. What happens is, when we click on the link, the content shows within the iFrame and not on the actual webs开发者_开发问答ite (which contains the iFrame).

We already tried putting target = _top like so:

<a href='http://$host/ourwebsite.php?no=$prikey&...etc' target='_top'>

And the links do open like other pages on the actual website (meaning, not inside the iFrame). However, the URL changes to show the entire URL of the iFrame meaning it shows something like (not exactly, just a sample to demonstrate it):

http://www.ourwebsite.com/somefile.php?no=223&jedkdooe39932fkdjkdfaf23033003=www.referencedsite.com/index.php

instead of just...

http://www.ourwebsite.com/somefile.php

The worst thing is, when we go to any other page, the URL on the address bar keeps showing the iFrame URL, even if those pages aren't actually inside the iFrame.

Is there a way to link from the iFrame and show the URL (when the link is clicked) of the actual website and not the URL of the iFrame? Like mask it or something?


Hi

In order to get the links within the iframe to load within the parent document, you need to specify this on the links themselves with the target attribute:

<a href="page.html" target="_parent">link to parent</a> 
0

精彩评论

暂无评论...
验证码 换一张
取 消