js取消显示confirm确认框的域名或地址

没取消前效果(难免有点难看)

去除后的效果 

实现代码 

$(document).ready(function(){
        // 弹出框取消域名地址
        window.alert = function(name){
	        var iframe = document.createElement("IFRAME");
	        iframe.style.display="none";
	        iframe.setAttribute("src", 'data:text/plain,');
	        document.documentElement.appendChild(iframe);
	        window.frames[0].window.alert(name);
	        iframe.parentNode.removeChild(iframe);
       	}
 
	    // 确认框取消域名地址
	    window.confirm = function (message) {
	        var iframe = document.createElement("IFRAME");
	        iframe.style.display = "none";
	        iframe.setAttribute("src", 'data:text/plain,');
	        document.documentElement.appendChild(iframe);
	        var alertFrame = window.frames[0];
	        var result = alertFrame.window.confirm(message);
	        iframe.parentNode.removeChild(iframe);
	        return result;
	    };
	});
function sc(plId) {
		if(confirm('该操作数据不可找回,您确定删除吗?')){
			$.post('${base}/front/weixin/system/delete.chtml', {
				plId: plId
			}, function(data) {
				var data = eval('(' + data + ')');
				if (data.result == "success") {
					alert("删除成功");
					location.reload();
				} else {
					alert(data.msg);
				}
			});
		}else{
			return;
		}
	}

猜你喜欢

转载自blog.csdn.net/qq_17211063/article/details/131221698