- <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 内部
页面大小变化事件
最新推荐文章于 2023-02-27 18:32:37 发布