如何定制弹出窗口的大小及其位置

来源:互联网 发布:opencv可以用c语言吗 编辑:程序博客网 时间:2024/04/25 06:23
  弹出窗口本不属于ASP,不过javascript与ASP还是有点亲戚关系。
一、最简单的自动弹出窗口
在主窗口A中加入以下代码:
<SCRIPT LANGUAGE="javascript">
window.open ("页面B地址","newwindow", "height=450, width=520, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no")
</SCRIPT>
打开A时就会自动弹出页面B

二、定义调用弹出窗口
在页面中加入以下代码:
<SCRIPT language=javascript>
<!--
function call(htmlurl){
var
newwin=window.open(htmlurl,"newsssWin","top=50,left=150,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=320,height=300");
newwin.focus();
return false;
}
//-->
</SCRIPT>

用下面的方法调用:
<a href=/'连接地址/' onclick=/'return call(this.href);/' target=_blank>连接名称</a>


点击“连接地址”就会弹出播放的小窗口。

三、能自动关闭的弹出窗口
在主窗口A中加入以下代码:
<SCRIPT LANGUAGE="javascript">
window.open ("b.htm","newwindow", "height=450, width=520, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no")
</SCRIPT>

页面b的代码如下:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body onload="window.setTimeout(/'CloseWindow.Click()/',2000)">
<div align="center">
<p> </p><p><object id="CloseWindow" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
    <param name="Command" value="Close">
  </object> <font size="5" color="#FF0000"><b>欢迎光临<br><br>再见!</b></font><font size="5">
  </font></p>
</div>
</body>
</html>
 
原创粉丝点击