<script LANGUAGE=”javascript”>
<!–
//window.open (‘com.htm’, ‘newwindow’, ‘ height=418, width=400,top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no’) –>
</script>
不加修饰的弹出窗口 示例代码1:
<script LANGUAGE=”JavaScript”>
<!–
window.open(‘http://www.google.com’); //–>
</script>
修饰弹出窗口 示例代码2:
<script language=”JavaScript1.2″ type=”text/JavaScript1.2″>
var popUpWin = 0;
function popUpWindow() {
//判断该窗口(popUpWin)是否已经存在,如果已经存在,则先关闭窗口,然后再打开新窗口
if (popUpWin) {
if (!popUpWin.closed) popUpWin.close();
}
//根据参数定位弹出窗口的展示位置
popUpWin = window.open(‘page.htm’, ‘popUpWin’, ‘toolbar=no,location=no, directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width=100,height=100, left=100,top=100,screenX=100,screenY=100’);
}
</script>
弹出窗口参数一览 弹出窗口的命令格式:”window.open(‘URLStr’, ‘WindowName’, ‘Property’);”,其中:
1.window.open命令用于在网页上弹出一个新窗口。
2.URLStr:弹出窗口所显示的页面
3.WindowName:弹出窗口的名称,可以任意指定,也可以用”来代替
4.Property:用于控制弹出窗口显示的属性,具体可控制的参数有:
5.Toolbar:是否显示浏览器工具栏,yes为显示,no为不显示
6.Location:是否显示游览器地址栏,yes为显示,no为不显示
7.Directories:是否显示目录按钮,yes为显示,no为不显示
8.Status:是否显示状态栏,yes为显示,no为不显示
9.Menubar:是否显示菜单条,yes为显示,no为不显示
10.Scrollbar:是否激活水平和垂直流动条,yes为显示,no为不显示
11.Resizable:是否可以改变窗口大小,yes为显示,no为不显示
12.Width:指定窗口的宽度,以像素为单位
13.Height:指定窗口的高度,以像素为单位
14.Left:指定窗口距屏幕左端的距离,以像素为单位
15.Top:指定窗口距屏幕顶端的距离,以像素为单位
16.screenX:等同于Left属性
17.screenY:等同于Top属性 特效窗口示例 通过函数调用控制弹出窗口
如”示例代码2″所定义的弹出窗口,在没有调用popUpWindow方法之前,该窗口是不会自动弹出的,
下面我们来看几种常用的调用方法:
<script language=javascript>
document.write(“”);
ad_dst = ad_dst + 1;
</script>
<object codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0
height=250 width=350 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000>
</object>
页面加载时自动弹出窗口
<body onLoad=”javascript:popUpWindow();”>
页面关闭时自动弹出窗口
<body onUnLoad=”javascript:popUpWindow();”>
通过链接或者按钮触发弹出窗口
<a href=”#” onClick=” javascript:popUpWindow();”>
<input type=”button” name=”弹出窗口” onClick=” javascript:popUpWindow();”>
弹出窗口定时关闭 在弹出的窗口中加入下面一小段代码,弹出的窗口就会在20秒后自动关闭。(这段代码要加在弹出窗口中,而不是主页上)
<script language=”javascript”> function closeit() { setTimeout(“self.close()”,10000) //毫秒 } </script>
将这段代码加入<head>标签内,然后再修改<body>标签为
<body onLoad=”closeit()”>就可以了。
为弹出窗口加上一个关闭按钮 在弹出的窗口中加入下面代码,页面上会多出一个按钮,
单击这个按钮,弹出窗口会自动关闭,而不会有任何提示。
<input TYPE=’BUTTON’ VALUE=’关闭’ onClick=’window.close()’>
function showMsg(index) {
window.open(“/tip/Tip_Page.php?id=”+index, “”, “scrollbars=yes,fullscreen=no,channelmode=no,location=no,toolbar=no,status=no,menubar=no;resizable=no,width=320,height=300″); }
<script language=”JavaScript”>
<!–
settimer = (newwina()) function newwina() {
var urlname; var attribution; attribution = “Toolbar = no,menubar=no,scrollbars=no,status=no,location=no,resizable = no,directories=no”; URLname = “http://snowman.3322.net”; window.open(URLname,””,attribution); }
// –>
</script>
<script language=”JavaScript”>
function openpage(url) { var newwin=window.open(url,”NewWin”,”toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=260″); newwin.focus(); return false; }
</script>
<script language=”javascript”>
function to_branch(branch_name){
if (branch_name==”999″) return;
var win_style=”left=0,top=0,width=1000,height=700,toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes”; window.open(branch_name,””,win_style);
}
function to_overseas_branch(branch_name){
if (branch_name==”999″) return; var win_style=”left=0,top=0,width=1000,height=700,toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes”; window.open(branch_name,””,win_style); }
function MM_openBrWindow(theURL,winName,features) {
//v2.0
window.open(theURL,winName,features); }
</script>