【发布时间】:2014-11-28 06:30:54
【问题描述】:
我有一个使用 WP 构建并使用 SSL 的网站。在我网站的一个页面上,我添加了对另一个 http 网站的 iframe 调用。
这是我的 iframe 调用:
<div class="embed-responsive embed-responsive-16by9">
<iframe src="//childwebsite.com/" target="_blank"></iframe>
</div>
iframe 显示正确。现在,当您单击 iframe 中的任何内容时,Chrome 会显示一条消息,说
混合内容:“https://parentwebsite.com”处的页面通过 HTTPS 加载,但请求了不安全的资源“http://childwebsite.com”。此请求已被阻止;内容必须通过 HTTPS 提供。
我正在寻找的是当用户在 iframe 内单击时,在浏览器中打开一个新选项卡并让用户被重定向到子网站上的特定位置。
我尝试将 target="_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');
}
我们将不胜感激。
【问题讨论】:
标签: javascript wordpress iframe