简体   繁体   中英

How do I open new links outside of an iframe?

Is there any way to make an iframe act as if it were part of the page. Such as when I click a link, it either will open the links in a new tab/window by default, or have it so that when a link is clicked, it will open in the same window, but not just the iframe?

You can just set the target attribute. To open in the current top window (top frame):

<a href="http://example.com" target="_top">Link Text</a>

Or to open in a new window:

<a href="http://example.com" target="_blank">Link Text</a>

There's also _parent for the parent window (not necessarily the top) and _self for the current window (the default).

Do you have control of the content that is in the iframe ?

You could use target=_top for the links.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM