日期:2014-05-16  浏览次数:20478 次

js resizeTo resizeBy 的用法记录

<!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>resize</title>

</head>
<body>

Width:<input type="text" name="" id="width" value="500" /> <br />
Height:<input type="text" name="" id="height" value="500" /><br />
<input type="button" value="resizeTo" id="sizeTo" onclick="sizeTo()" />
<input type="button" value="resizeBy" id="sizeBy" onclick="sizeBy()" />

<script type="text/javascript">
function G(id){return document.getElementById(id);}

var w,h;

// resizeTo() 方法用于把窗口大小调整为指定的宽度和高度。
function sizeTo() {
    w = G("width").value;
    h = G("height").value;
    resizeTo(w,h);
    console.log("sizeTo: w="+w+";h="+h);
}

// resizeBy() 方法用于根据指定的像素来调整窗口的大小。
function sizeBy() {
    w = G("width").value;
    h = G("height").value;
    resizeBy(w,h);
    console.log("sizeBy: w="+w+";h="+h);
}

</script>
</body>
</html>
?
1 楼 zzzz3621 2011-12-01  
只在IE上有效果诶
而且resizeBy好像有BUG

console.log("sizeBy: w="+w+";h="+h);
这句好像也没效果