Javascript 阻止用户在Iframe内导航

Javascript 阻止用户在Iframe内导航,javascript,html,iframe,Javascript,Html,Iframe,因为我被允许在iframe加载之后运行javascript行 我执行了这个脚本 window.onbeforeunload = function(e) {e.preventDefault();} // it makes the user navigating without issues 我试过这个 window.onbeforeunload = function() {return '';} // it promot a confirmation message if the use w

因为我被允许在iframe加载之后运行javascript行

我执行了这个脚本

window.onbeforeunload = function(e) {e.preventDefault();} 
// it makes the user navigating without issues
我试过这个

window.onbeforeunload = function() {return '';} 
// it promot a confirmation message if the use will leave the page or not

还有其他解决方案吗?

如何覆盖链接的单击事件处理程序

window.onload = function() {
    var links = document.getElementsByTagName("a");
    for(var i in links)
        links[i].onclick = function() {return false; };
};