这个问题如此简单,必须有一个解决方案。
我创建了一个jsFiddle for it .
代码是:
$(function(){
$('<iframe>').attr('src', 'xyz://test').appendTo('body');
});
附加 iframe 后,IE 将导航到 src。我在IE9和IE10下都进行了测试。在 Firefox、Chrome 或 Safari 中不会发生这种情况。
仅当使用自定义协议(protocol)(例如 xyz://而不是 http://)时才会发生这种情况。
感谢任何帮助。
最佳答案
Application Protocols
In contrast to Pluggable Protocols, Application Protocols are much simpler. Rather than returning content to the browser, they simply enable the browser (or another program like a word processor or PDF reader) to launch a program, passing the requested URL to that program. Common examples of Application Protocols include the mailto:[1] news:, and onenote: protocols.
关于javascript - 添加具有自定义协议(protocol)的 iframe 会导致 IE 导航到 iframe 源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24520751/