码迷,mamicode.com
首页 > 其他好文 > 详细

禁止iframe页面时产生历史记录

时间:2018-03-14 12:57:12      阅读:876      评论:0      收藏:0      [点我收藏+]

标签:nbsp   before   移除   产生   main   open   历史记录   历史   var   

解决方案:每次iframe都是重新创建

不废话,直接上代码

/**
 * 在ifrema打开链接
 * @param url
 */
function openIframe(url){
    var oldIframe = document.getElementById("main-content");
    var iframe = document.createElement(‘iframe‘);
    iframe.setAttribute("id", "main-content");//添加id属性
    iframe.setAttribute("onload","setIframeHeight()");//添加onLoad事件
    iframe.src = url;
    oldIframe.parentNode.insertBefore(iframe,oldIframe);//添加新的ifrema
//移除旧的iframe
    if (!!oldIframe){
        oldIframe.src="about:blank";
        oldIframe.parentNode.removeChild(oldIframe);
    }
}

 

禁止iframe页面时产生历史记录

标签:nbsp   before   移除   产生   main   open   历史记录   历史   var   

原文地址:https://www.cnblogs.com/liuwt365/p/8566285.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!