我是靠谱客的博主 长情毛豆,最近开发中收集的这篇文章主要介绍利用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 οnclick=y(" h**p://www.aaaa.com") class=h>aaaa</a>
<a οnclick=y(" h**p://www.bbbb.cn") class=h>bbbb</a>
<a οnclick=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>
</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弹出窗口并限制大小的几种方法的全部内容,希望文章能够帮你解决利用JAVASCRIPT弹出窗口并限制大小的几种方法所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(60)

评论列表共有 0 条评论

立即
投稿
返回
顶部