原文链接:https://blog.csdn.net/wlangduhua/article/details/81839384
在手机移动端开发的时候可能遇到iPhone手机弹窗中有特殊url字符串的问题,如下
解决如下:
window.alert = function(name){
var iframe = document.createElement("IFRAME");
iframe.style.display="none";
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;
}
将上面的js代码引入到有alert和confirm的页面里面
<script type="text/javascript" src="${ctxStatic}/js/iframeAlert.js"></script>