js window.open 打开新窗体 参数设置

时间:2022-07-10 11:24:32

<!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>
</head>

<form>
    <input type="button" name="Button1" value="CN-Bruce" onclick="WinOpen()" />

<button onclick="window.open('http://www.aspxhome', '', 'width=800,height=300')">open1</button>

<button onclick="var newwin = window.open('http://www.aspxhome', '', 'width=800,height=300'); newwin.moveTo(50, 50), newwin.resizeTo(800, 300)">open2</button>
    <button onclick="window.showModelessDialog('http://www.aspxhome', '', 'dialogWidth:800px;dialogHeight:300px')">open3</button>
    <a href="#" onclick="window.open('http://www.aspxhome','target','param')">a11</a>
</form>
<body>
</body>
</html>

<!--window.open 参考文档:http://www.cnblogs.com/mfryf/archive/2013/06/10/3130286.html-->

<script language="JavaScript">

function WinOpen() {
        //得到页面高度
        var yScroll = (document.documentElement.scrollHeight > document.documentElement.clientHeight) ? document.documentElement.scrollHeight : document.documentElement.clientHeight;

//self.resizeBy = yScroll;
        //得到页面宽度
        var xScroll = (document.documentElement.scrollWidth > document.documentElement.clientWidth) ? document.documentElement.scrollWidth : document.documentElement.scrollWidth;

//self.resizeTo(xScroll - 200, yScroll - 200);

//self.moveTo(xScroll - 200, yScroll - 200);
        var x = xScroll - 200;
        var y = yScroll - 100;

//mesg = open("http://www.aspxhome", "DisplayWindow", "toolbar=no,,menubar=no,location=no,scrollbars=no");
        //mesg.document.write("<HEAD><TITLE>中国asp之家</TITLE></HEAD>");
        //mesg.document.write("<CENTER>http://www.aspxhome</CENTER>");
        //window.open('http://www.aspxhome', '', 'width="' + x + 'px",height="' + y + '"px');

var featrures = "toolbar=no,menubar=no,location=no,scrollbars=yes,";
        var newwin = window.open('http://www.aspxhome', 'target', featrures);
        newwin.resizable = "yes";
        newwin.moveTo(100, 10);
        newwin.moveBy(100, 80);
        
        top = 200
        //       newwin.resizeTo(x, y);
    }
    //得到页面高度
    var yScroll = (document.documentElement.scrollHeight > document.documentElement.clientHeight) ? document.documentElement.scrollHeight : document.documentElement.clientHeight;

//self.resizeBy = yScroll;
    //得到页面宽度
    var xScroll = (document.documentElement.scrollWidth > document.documentElement.clientWidth) ? document.documentElement.scrollWidth : document.documentElement.scrollWidth;

//self.resizeTo(xScroll - 200, yScroll - 200);

//self.moveTo(xScroll - 200, yScroll - 200);

</script>