【问题标题】:Open HTTPS website on the same iframe在同一个 iframe 上打开 HTTPS 网站
【发布时间】:2018-12-31 11:13:50
【问题描述】:

我正在尝试使用链接控制 iframe 内安全网站的导航,但它一直在新选项卡或窗口中打开。它在不安全的网站中正常工作。这是我的代码:

<a href="#" onclick=window.open("https://www2.ecinteractiveplus.com/0463/Product/OND/VBD50BK/","iframe1");>Binders</a>
<a href="#" onclick=window.open("https://www2.ecinteractiveplus.com/0463/Product/UPG/BLU113/","iframe1");>Folders</a>

<iframe name="iframe1" src="https://www2.ecinteractiveplus.com/0463" style="min-height: 1100px;height:100%; min-width: 600px; width:100%;"></iframe>

非常感谢任何帮助!

【问题讨论】:

    标签: javascript html iframe https hyperlink


    【解决方案1】:

    这可行,只要确保 iframe 的 javascript 代码从 same origin 加载即可。

    <a href="https://www2.ecinteractiveplus.com/0463/Product/OND/VBD50BK/" target="iframe1">Binders</a>
    <a href="https://www2.ecinteractiveplus.com/0463/Product/UPG/BLU113/" target="iframe1">Folders</a>
    
    <iframe name="iframe1" src="https://www2.ecinteractiveplus.com/0463" style="min-height: 1100px; height:100%; min-width: 600px; width:100%;"></iframe>
    

    【讨论】:

    • 您好,感谢您的帮助,但仍然没有用。在这里测试:jsfiddle.net/c09rL1z4
    • 该代码有效,它在不同的窗口中打开,因为“你不能使用 JavaScript 访问具有不同来源的
    • 这就解释了一切。你对此有什么替代建议吗?非常感谢!
    • 如果您使用的是 linux/unix,那么正在开发中,您可以编辑 /etc/hosts 文件并将 localhost 更改为您需要的域,在生产中只需确保在同一来源上运行应用程序,在我的回答中,有一个指向同源政策文档的链接。
    • 知道了。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2012-07-31
    • 2023-03-29
    • 1970-01-01
    • 2011-05-16
    • 1970-01-01
    • 1970-01-01
    • 2016-10-06
    • 1970-01-01
    相关资源
    最近更新 更多