- <body onresize="alert('You have changed the size of the window')">
- </body>
<
head
>
03.
<
script
type
=
"text/javascript"
>
04.
function resizeFunc(){
05.
alert(Math.random());
06.
}
07.
</
script
>
08.
</
head
>
09.
<
body
>
10.
<
div
id
=
"box"
style
=
"width:100%"
>
11.
<
div
>Text...</
div
>
12.
</
div
>
13.
<
script
type
=
"text/javascript"
>
14.
var Container = document.getElementById("box");
15.
Container.attachEvent("onresize",resizeFunc); //方法一
16.
//Container.onresize = resizeFunc; //方法二,支持ff
17.
</
script
>
18.
</
body
>
19.
</
html
>
把 window 對象替換爲 DOM 內部
頁面大小變化事件
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.