JAVASCRIPT弹出窗口限制大小的几种方法


JAVASCRIPT弹出窗口并限制大小的几种方法--
方法1:
<SCRIPT LANGUAGE="javascript">
window.open (" h**p://www.163.com","newwindow", "height=450, width=520, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no,
status=no")
</SCRIPT>

方法2:
<script language="javascript" type="text/javascript">
function y(e){window.open(e,"","width=400,height=300,scrollbars=1")}
</script>
<style>.h{cursor:hand}</style>
<a onclick=y(" h**p://www.aaaa.com") class=h>aaaa</a>
<a onclick=y(" h**p://www.bbbb.cn") class=h>bbbb</a>
<a onclick=y(" h**p://www.cccc.com") class=h>cccc</a>
方法3:
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<script language=javascript>
<!--
function openwindow( url, winName, width, height)
{
xposition=0; yposition=0;
if ((parseInt(navigator.appVersion) >= 4 ))
{
xposition = (screen.width - width) / 2;
yposition = (screen.height - height) / 2;
}
theproperty= "width=" + width + ","
+ "height=" + height + ","
+ "location=0,"
+ "menubar=0,"
+ "resizable=1,"
+ "scrollbars=0,"
+ "status=0,"
+ "titlebar=0,"
+ "toolbar=0,"
+ "hotkeys=0,"
+ "screenx=" + xposition + "," //仅适用于Netscape
+ "screeny=" + yposition + "," //仅适用于Netscape
+ "left=" + xposition + "," //IE
+ "top=" + yposition; //IE
window.open( url,winName,theproperty );
}
//-->
</script>
<a href="javascript:openwindow('http://www.iecn.net/forum/index.php','anyname',300,300)">打开窗口试试</a> _fcksavedurl=""javascript:openwindow('http://www.iecn.net/forum/index.php','anyname',300,300)">打开窗口试试</a>" _fcksavedurl=""javascript:openwindow('http://www.iecn.net/forum/index.php','anyname',300,300)">打开窗口试试</a>"
</body>
</html>

方法4:(推荐)
<script language="javascript" type="text/javascript">
function showdialog(url)
{
var iw=320;
var ih=200;
var itop=(window.screen.height-ih)/2;
var ileft=(window.screen.width-iw)/2;
window.open(url,"Detail","Scrollbars=no,Toolbar=no,Location=no,Direction=no,Resizeable=no,   Width="+iw+" ,Height="+ih+",top="+itop+",left="+ileft) ;
}
</script>  

你可能感兴趣的:(JAVASCRIPT弹出窗口限制大小的几种方法)