试图获得一个居中弹出的时间设定值,像这样的东西后显示为中心的弹出的Javascript:延迟使用的setTimeout
<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>
弹出显示立即,但然后我收到一个无效的参数错误。建议?
setTimeo ut(function(){popup(''test/login.html')},5000); – 2012-07-23 19:11:58