javascript 使用Javascript自动打开弹出新窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19293014/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
automatic open pop-up new window using Javascript
提问by mrTom
How to open pop-up new window when load page using Javascript?
使用Javascript加载页面时如何打开弹出新窗口?
I want, when a website load, it will automatic open popup new window.
我想,当网站加载时,它会自动打开弹出新窗口。
I use the following:
我使用以下内容:
<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>
Not work??
不行??
回答by Eduardo Cuomo
You can't do this. It's a browser security feature. Try using jQuery UI: Dialog
你不能这样做。这是浏览器的安全功能。尝试使用jQuery UI: Dialog
Example:
例子:
<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>
回答by nitishk
try this-
试试这个-
<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>
Paste this code in head section of your website.
将此代码粘贴到您网站的头部部分。
回答by MS Wani
var newwindow;
function poptastic(url)
{
newwindow=window.open(url,'name','height=400,width=200');
if (window.focus) {newwindow.focus()}
}
回答by babonamu
<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>