使用Javascript / jQuery在当前窗口后面打开一个窗口 [英] Open a window behind the current window using Javascript/jQuery
问题描述
我想在点击时打开一个窗口,但是我想在当前窗口后面打开它,或者当新窗口打开时它应该最小化它自己。我已经创建了一个函数,但实际上它没有用。
I want to open a window on click, but I want to open it behind the current window, or when the new window opens it should minimize itself. I have made a function but it actually did not work.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function wn(){
var mm=window.open('http://www.google.com','newwindow','width=200, height=200', "_blank");
}
</script>
</head>
<body>
<a href="#" onclick="wn()">click</a>
</body>
推荐答案
编辑
父窗口HTML
<script language="JavaScript" type="text/javascript">
function openPopUP() {
window.open('mywindow.html','NewWin',
'toolbar=no,status=no,width=350,height=135')
}
</script>
<body onLoad="openPopUP();">
or
<a href="javascript:openPopUP();">Click to open popup</a>
子窗口即弹出窗口文件
下面的脚本应该在子窗口中。子窗口将打开,并在1秒后自动隐藏。 setTimeout
方法中指定的值 1000
是子窗口打开的持续时间(以毫秒为单位)。如果希望子窗口打开更长时间,可以增加此超时持续时间。
The below script should be in the child window. The child window will open and will automatically be hidden after 1 second. The value 1000
specified in the setTimeout
method is the duration in milliseconds for which the child window will be open. You can increase this timeout duration if you want the child window to be open longer.
<body onLoad="setTimeout('window.blur()', 1000);"
onFocus="setTimeout('window.blur()', 1000);">
这可能对您有用:添加此行您孩子窗口的 onload
事件中的代码...
This might work for you: Add this line of code in the onload
event of your child window...
window.parent.opener.focus();
这篇关于使用Javascript / jQuery在当前窗口后面打开一个窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!