尝试在设定的时间值后显示居中的弹出窗口,如下所示:
<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, 'windowname5', params);
if (window.focus) {
newwin.focus()
}
setTimeout(popup('`test/login.html'), 5000);
return false;
}
//-->
//]]>
</script>
但弹出窗口永远不会显示。如果我这样写:
<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, 'windowname5', params);
if (window.focus) {
newwin.focus()
}
return false;
}
setTimeout(popup('`test/login.html'), 5000);
//-->
//]]>
</script>
弹出窗口立即显示,但随后我收到一个 Invalid Argument 错误。建议?