javascript - 添加具有自定义协议(protocol)的 iframe 会导致 IE 导航到 iframe 源

标签 javascript internet-explorer iframe

这个问题如此简单,必须有一个解决方案。

我创建了一个jsFiddle for it .

代码是:

$(function(){
    $('<iframe>').attr('src', 'xyz://test').appendTo('body');
});

附加 iframe 后,IE 将导航到 src。我在IE9和IE10下都进行了测试。在 Firefox、Chrome 或 Safari 中不会发生这种情况。

仅当使用自定义协议(protocol)(例如 xyz://而不是 http://)时才会发生这种情况。

感谢任何帮助。

最佳答案

这可能有帮助http://blogs.msdn.com/b/ieinternals/archive/2011/07/14/url-protocols-application-protocols-and-asynchronous-pluggable-protocols-oh-my.aspx

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/

相关文章:

javascript - iFrame WYSIWYG 字体大小不会重置

javascript - jquery 焦点回到相同的输入字段,错误不适用于所有浏览器

asp.net - 检测IE设置: check for newer versions of stored pages "never"

javascript - 是否可以只从 youtube iframe 嵌入播放器中删除 "watch later"和 "share"按钮

html - iframe 中的历史 pushState,影响 Chrome 中的父窗口布局?

javascript - 具有任意多条线(和特定数据格式)的 D3 线图

javascript - 如何使用 react 模态显示没有背景效果的模态?

javascript - 使用下拉菜单自动更改代码

javascript - contenteditable 选定的文本保存和恢复

internet-explorer - 使 Selectivizr 无法正常工作