然后转到未定义到test.com。
如何进入http://url.com然后http://test.com然后http://anotherdesiredurl.com
<head>
<script type="text/javascript">
<!--
function popup(url) {
var width = 300;
var height = 200;
var left = (screen.width - width) / 2;
var top = (screen.height - height) / 2;
var params = 'width=' + width + ', height=' + height;
params += ', top=' + top + ', left=' + left;
params += ', directories=no';
params += ', location=no';
params += ', menubar=no';
params += ', resizable=no';
params += ', scrollbars=no';
params += ', status=no';
params += ', toolbar=no';
newwin = window.open(url, 'popup', 'params');
if (window.focus) {
newwin.focus()
}
return false;
}
setTimeout(function() {popup('http://www.test.com/'); }, 8000)
//-->
//]]>
</script>
<head>
<body>
<input type="button" value="Click Blitch" onclick="popup();"/>
</body>
答案 0 :(得分:1)
newwin = window.open(url, 'popup', 'params');
我原以为:
newwin = window.open(url, 'popup', params);
但我不确定它与你的pb有关
答案 1 :(得分:0)
因为你在这里没有将参数传递给popup
函数:
<input type="button" value="Click Blitch" onclick="popup();"/>
你应该传递一个参数,或者检查函数是否未定义,然后分配一些URL
答案 2 :(得分:0)
试试这个:
<强>的JavaScript 强>
function popup(url) {
var width = 300;
var height = 200;
var left = (screen.width - width) / 2;
var top = (screen.height - height) / 2;
var params = 'width=' + width + ', height=' + height;
params += ', top=' + top + ', left=' + left;
params += ', directories=no';
params += ', location=no';
params += ', menubar=no';
params += ', resizable=no';
params += ', scrollbars=no';
params += ', status=no';
params += ', toolbar=no';
newwin = window.open(url, 'popup', 'params');
if (window.focus) {
newwin.focus()
}
return false;
}
function openWindows() {
popup('http://url.com');
popup('http://text.com');
popup('http://http://anotherdesiredurl.com');
}
<强> HTML 强>
<input type="button" value="Click here" onclick="openWindows();"/>
如果要在超时后更改相同弹出窗口的位置,可以将JavaScript更改为:
function popup(url, win) {
var width = 300;
var height = 200;
var left = (screen.width - width) / 2;
var top = (screen.height - height) / 2;
var params = 'width=' + width + ', height=' + height;
var newwin = win;
params += ', top=' + top + ', left=' + left;
params += ', directories=no';
params += ', location=no';
params += ', menubar=no';
params += ', resizable=no';
params += ', scrollbars=no';
params += ', status=no';
params += ', toolbar=no';
if (newwin) {
newwin.location = url;
} else {
newwin = window.open(url, 'popup', 'params');
}
if (window.focus) {
newwin.focus()
}
return newwin;
}
function openWindows() {
var win = popup('http://url.com');
setTimeout(function () {
popup('http://text.com', win);
}, 2000);
setTimeout(function () {
popup('http://http://anotherdesiredurl.com', win);
}, 4000);
}