我试图在页面加载时立即弹出,但所有浏览器都阻止它并且不让弹出窗口工作,这是我的代码:
<html>
<head>
<script>
function codeAddress() {
javascript:void window.open('http://google.com','1411977082597','width=750,height=550,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');return false;
}
window.onload = codeAddress;
</script>
</head>
<body>
</body>
</html>
有解决方案吗?
最佳答案
不需要下面的代码
javascript:void
在 html 标签上编写 javascript 时使用此代码
function codeAddress() {
window.open('http://google.com','1411977082597','width=750,height=550,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');
}
检查您的浏览器是否启用了 javascript。
检查您的浏览器是否允许弹出。
使用 Javascript 允许弹出窗口工作是不可能的。
关于javascript - 使弹出窗口加载工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26095238/