我正在尝试在加载页面时立即弹出一个弹出窗口,但所有浏览器都阻止它并且不让弹出窗口工作,这是我的代码:
<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>
有一个解决方案吗?
答案 0 :(得分:1)
不需要以下代码
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 enable。
检查您的浏览器允许弹出窗口。
允许弹出窗口无法使用Javascript工作。
答案 1 :(得分:0)
您可以通过在jquery document.ready方法中调用方法来完成此操作。喜欢:
$(document).ready(function(){
codeAddress();
})