<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>弹出窗口几种方法</title>
<script language="网页特效">
<!--
window.open ("openvps教程.html", "newwindow", "height=718, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no")
//写成一行
-->
</script>
</head>
<body>
</body>
</html>
参数解释:
<script language="网页特效"> 网页特效脚本开始;
window.open弹出新窗口的命令;
'page.html'弹出窗口的文件名;
'newwindow'弹出窗口的名字(不是文件名),非必须,可用空''代替;
height=100窗口高度;
width=400窗口宽度;
top=0窗口距离屏幕上方的象素值;
left=0窗口距离屏幕左侧的象素值;
toolbar=no是否显示工具栏,yes为显示;
menubar,scrollbars表示菜单栏和滚动栏。
resizable=no是否允许改变窗口大小,yes为允许;
location=no是否显示地址栏,yes为允许;
status=no是否显示状态栏内的信息(通常是文件已经打开),yes为允许;
</script> 网页特效脚本结束
控制弹出窗口次数
<script>
function openwin()
{window.open("page.html","","width=200,height=200")}
function get_cookie(name)
{var search = name + "="
var returnvalue = "";
if (documents.cookie.length > 0) {
offset = documents.cookie.indexof(search)
if (offset != -1) {
offset += search.length
end = documents.cookie.indexof(";", offset);
if (end == -1)
end = documents.cookie.length;
returnvalue=unescape(documents.cookie.substring(offset,end))
}
}
return returnvalue;
}
function loadpopup(){
if (get_cookie('popped')==''){
openwin()
documents.cookie="popped=yes"
}
}
</script>
下面的代码可以控制弹出窗口在网页居中
<script language="javascript">
function openwin(u, w, h) {
var l = (screen.width - w) / 2;
var t = (screen.height - h) / 2;
var s = 'width=' + w + ', height=' + h + ', top=' + t + ', left=' + l;
s += ', toolbar=no, scrollbars=no, menubar=no, location=no, resizable=no';
open(u, 'owin', s);
}
</script>
<a href="javascript:void(openwin('http://www.111cn.net/', 600, 500));">test</a>