美文网首页
去掉移动端alert和confirm弹出框携带url链接

去掉移动端alert和confirm弹出框携带url链接

作者: 呼兰呦 | 来源:发表于2018-06-08 14:56 被阅读0次
//去掉移动端alert和confirm弹出框携带url链接
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);
};
//去掉移动端alert和confirm弹出框携带url链接
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;
};

相关文章

网友评论

      本文标题:去掉移动端alert和confirm弹出框携带url链接

      本文链接:https://www.haomeiwen.com/subject/ywlasftx.html