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

解决方案:每次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);
    }
}
原文地址:https://www.cnblogs.com/liuwt365/p/8566285.html