-1
我希望这里有人能够帮助,我感谢我的提前。从iframe内部导航到链接
我有一个iframe(在我的域名),当有人点击iframe中的链接我不想让该链接自动打开,我需要它去一个功能,将导航到该链接后添加一些东西这一页。
我用这个功能来填充的iframe
function setIframeHtml(html) {
var iframe = document.getElementById("myFrame");
var doc = iframe.document;
if (iframe.contentDocument) {
doc = iframe.contentDocument; // For NS6
}
else if (iframe.contentWindow) {
doc = iframe.contentWindow.document; // For IE5.5 and IE6
}
// Put the content in the iframe
doc.open();
doc.writeln(html);
doc.close();
navigating = false;
}
的HTML参数的函数得到的是增加我的东西后要加载的页面。
当我做到这一点从iframe中我得到一个错误说
Cannot read property 'document' of null
只有当我打电话从出一侧的功能,如果iframe中,它的工作原理。
任何想法如何让这个工作?