window.onload = function(){
window.resizeTo(800,600)//调整大小
window.moveTo(200,200)//移动位置}
但是这种方式好像只有在IE下有效,Firefox和Chrome无效,你自己试试。暂时不知道有什么其他兼容性好的办法。
JS如何设置并限制浏览器窗口的大小?
方法一:
<script> window.moveTo(0, 0)//移动窗口
window.resizeTo(800, 600)//改变大小 window.onresize=new Function("window.resizeTo(800, 600)") </script>方法二:
<SCRIPT>if (window != top) top.location.href = location.hrefself.resizeTo(800,600)</SCRIPT> 方法三:<script language="javascript"> function openWin() { var i=0 i = open("","","width=500,height=500") }</script>ajaxmenu根本就没有实现弹出DIV大小的参数!所以上面那段代码不能改变弹出窗口大小!要控制大小自已写一个函数下面是个例子://创建窗口/*
* 创建窗口(参数说明)
* wWidth:int 窗口宽度
* wHeight:int 窗口高度
* wMainID:主窗口id
* wTitleID:string 标题ID
* wTitleText:string 标题内容
* wShowID:string 窗口要显示的位置(层ID)
* wFileURL:string 模板文件位置
*/
function CreateWindow(wWidth, wHeight, wMainID, wTitleID, wTitleText, wShowID, wFileURL) {
xmlHttp = initXMLHttpClient()
xmlHttp.open("GET", wFileURL, false)
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText
var tHeight = window.screen.availHeight //alert("创建窗口函数:" + window.screen.availHeight)
document.getElementById(wShowID).innerHTML = response
document.getElementById(wMainID).style.width = wWidth
document.getElementById(wMainID).style.height = wHeight
document.getElementById(wMainID).style.position = "absolute"
document.getElementById(wMainID).style.left = document.body.clientWidth / 2 - wWidth / 2
//document.GetElementById(wMainID).style.top = "50%"
document.getElementById(wTitleID).innerText = wTitleText
wTether = true
wWindow = 0
wCount++
}
}
xmlHttp.send(null)
}