Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使IFrame链接在新窗口中打开?_Javascript_Wordpress_Iframe - Fatal编程技术网

Javascript 如何使IFrame链接在新窗口中打开?

Javascript 如何使IFrame链接在新窗口中打开?,javascript,wordpress,iframe,Javascript,Wordpress,Iframe,我有一个网站,这是建立使用可湿性粉剂和使用SSL。在我网站的一个页面上,我添加了对另一个http网站的iframe调用 这是我的iframe呼叫: <div class="embed-responsive embed-responsive-16by9"> <iframe src="//childwebsite.com/" target="_blank"></iframe> </div> iframe显示正确。现在,当你点击iframe中的任何东西

我有一个网站,这是建立使用可湿性粉剂和使用SSL。在我网站的一个页面上,我添加了对另一个http网站的iframe调用

这是我的iframe呼叫:

<div class="embed-responsive embed-responsive-16by9">
<iframe src="//childwebsite.com/" target="_blank"></iframe>
</div>
iframe显示正确。现在,当你点击iframe中的任何东西时,Chrome会显示一条消息,上面写着

混合内容:处的页面通过HTTPS加载,但请求的资源不安全。此请求已被阻止;内容必须通过HTTPS提供

我要寻找的是,当用户在iframe中单击时,在浏览器中打开一个新选项卡,让用户重定向到网站上的某个特定位置

我尝试将target=\u blank添加到iframe中,但没有成功

我还添加了以下JS,但它不起作用

//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('smugmugGallery') );
//Get all links
var links = inside.getElementsByTagName('input');
//Loop throught links and set their attributes
for (var i = 0 ; i<links.length ; i++){
    links[i].setAttribute('target','_blank');
}

任何帮助都将不胜感激。

您这里有两个问题。SSL问题和跨域问题

您的SSL问题只能通过通过SSL提供iframed内容或通过非SSL提供父页面来解决。这将删除您看到的安全警报

如果iframed内容来自另一个域,则无法对其进行控制,至少对于跨浏览器的目的来说,这并不容易

从Mozilla开发站点:

试图访问框架内容的脚本受 相同来源策略,并且无法访问中的大多数属性 从其他域加载的其他窗口对象。这 也适用于帧内试图访问其父帧的脚本 窗跨域通信仍然可以通过 window.postMessage


在iframe中使用base标记并重试一次

<base target="_blank" />

您可以查看有关Matt的更多信息谢谢您的回复。。。我可以让一个网站页面通过非SSL交付,而网站的其余部分通过SSL交付吗?@meher bala是的,你可以。