微信开发时,alert对话框 iphone显示URL 的问题

1442821724_621740

<script>
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(‘xxx’);
</script>

改进版:

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);
}
window.confirm = function(name){
var iframe = document.createElement(“IFRAME”);
iframe.style.display=”none”;
iframe.setAttribute(“src”, ‘data:text/plain,’);
document.documentElement.appendChild(iframe);
var result = window.frames[0].window.confirm(name);
iframe.parentNode.removeChild(iframe);
return result;
}

© 版权声明
THE END
喜欢就支持一下吧
点赞0
分享
评论 抢沙发

请登录后发表评论