iOS移动端(H5)alert/confirm提示信息去除网址(URL)

代码如下:

重写alert方法:


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);

};


重写confirm方法:


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;

};

你可能感兴趣的:(iOS移动端(H5)alert/confirm提示信息去除网址(URL))