怎樣在蘋果ios系統中,不讓alert和confirm彈窗中顯示url地址

原文鏈接:http://wanlimm.com/77201807135905.html

重寫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;
};

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章