简体   繁体   English

链接iframe以更改父窗口

[英]Links in an iframe to change the parent window

iv been recently building a website that has a table embeded in an iframe, now if I click a link from the embeded table it opens in the iframe. iv最近一直在构建一个网站,该网站在iframe中嵌入了表格,现在,如果我单击嵌入表格中的链接,则该链接会在iframe中打开。 On other forums I've heard everyone say all you need is to put target="_parent" , but it doesn't ever specify where to put it so I cant even test if it works 在其他论坛上,我听说每个人都说您需要做的只是放下target="_parent" ,但是它从来没有指定放置位置,所以我什至无法测试它是否有效

You can view a copy of my code here . 您可以在此处查看我的代码的副本。

I'm pretty sure that I need to change the following to make it work but I don't know what with 我很确定我需要更改以下内容才能使其正常工作,但我不知道该怎么做

output.document.write(desc[itemp].bold() +"<br>" + links[itemp].link(links[itemp])+ "<br>");

Any Help would be great 任何帮助都会很棒

您只需将其作为属性放置在标签中,例如:

<a href="http://www.bbc.co.uk/news" target="_parent">BBC News</a>

This code relies on the fact that 此代码依赖于以下事实:

'foo'.link('bar'); // "<a href="bar">foo</a>"

That method ( String.prototype.link ) doesn't give you the option to change target , you'd have to do this manually 该方法( String.prototype.link )不提供更改目标的选项,您必须手动执行此操作

'<a href="' + links[itemp] + '" target="_parent">' + links[itemp] + '</a>'

Though this code is exceedingly old (copyright 1997), so you may be better off having the whole thing rewritten and or not using it as an example to learn from. 尽管此代码非常古老(版权所有1997),所以最好重写整个代码,或者不以它为例进行学习。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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