iframe窗口中的链接可在新选项卡中打开

我已经多次看过这个问题了,很多答案似乎都暗示了基础target="_blank"技术。 但是,我以前曾经使用过这个; 但我目前的页面不起作用。 即使它确实奏效,我也认为它不是最好的选择; 因为我只想在iframe src=""的链接在新窗口中打开。 我正在跳过一个简单的解决方案,我可以在页面中添加内联。 我也尝试添加如下ID,并使用JavaScript,仍然是虚无…

  

JS

 $(document).ready(function(){ $("#frame1").attr("target","_blank"); }); 

基本上,目标是当用户在静态页面上的iframe中看到我的wordpress提要时; 一旦点击了post标题,它就会在新窗口中加载 – 因为它现在加载在同一个iframe中,因此没有提高可读性水平。

由于iFrame标签是针对相反的方向开发的,因此没有真正的解决方案。

 //pass the iframe to this iframe getting function function iframeRef( frameRef ) { return frameRef.contentWindow ? frameRef.contentWindow.document : frameRef.contentDocument } //Get Iframe var inside = iframeRef( document.getElementById('iframeID') ); //Get all links var links = inside.getElementsByTagName('a'); //Loop throught links and set their attributes for (var i = 0 ; i 

感谢meder

编辑由于iframe相同的源限制,我必须找到一个内部iframe来自同一来源的网站,以便您可以粘贴此代码

 //pass the iframe to this iframe getting function function iframeRef( frameRef ) { return frameRef.contentWindow ? frameRef.contentWindow.document : frameRef.contentDocument } //Get Iframe var inside = iframeRef( document.getElementById('IFwinEdit_Gadget_247730_3349') ); //Get all links var links = inside.getElementsByTagName('input'); //Loop throught links and set their attributes for (var i = 0 ; i 

到这个网站的控制台,看到输入改变颜色