1. 程式人生 > >手機頁面alert彈出框有url咋辦

手機頁面alert彈出框有url咋辦

在script中加入如下程式碼

window.alert = function(name){ // 重寫alert方法去掉ios下alert帶的url
        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);
 }