如何在使用Javascript加载页面时打开弹出新窗口?
我想,当一个网站加载时,它会自动打开弹出的新窗口。
我使用以下内容:
<script type="text/javascript">
function open_on_entrance(url,name)
{
window.open('http://www.google.com','google', ' menubar,resizable,dependent,status,width=300,height=200,left=10,top=10')
}
</script>
<body onload="open_on_entrance()"></body>
不行???
答案 0 :(得分:0)
你不能这样做。这是一个浏览器安全功能。尝试使用jQuery UI: Dialog
示例:
<html>
<head>
<meta charset="utf-8">
<title>jQuery UI Dialog - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script>
$(function() {
$( "#dialog" ).dialog();
});
</script>
</head>
<body>
<div id="dialog" title="Basic dialog">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
</body>
</html>
答案 1 :(得分:0)
试试这个 -
<script type="text/javascript">
window.onload = function() {
window.open('http://upcominggames2015.blogspot.in/','new games release',' menubar=0, resizable=0,dependent=0,status=0,width=300,height=200,left=10,top=10')
}
</script>
将此代码粘贴到您网站的主题部分。
答案 2 :(得分:-1)
<html>
<head>
<script type="text/javascript">
window.onload = function() {
window.open('http://www.google.com','google',' menubar=0, resizable=0,dependent=0,status=0,width=300,height=200,left=10,top=10')
}
</script>
<body>
</body>
</head>
</html>
答案 3 :(得分:-1)
var newwindow;
function poptastic(url)
{
newwindow=window.open(url,'name','height=400,width=200');
if (window.focus) {newwindow.focus()}
}