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

3,161次阅读
没有评论

共计 862 个字符,预计需要花费 3 分钟才能阅读完成。

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

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

正文完
 0
评论(没有评论)