document.body没有onresize()方法,window对象才有onresize() 方法, 但可以在<body>标签中写onresize属性,如:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>onresize</title>
</head>
<body onresize="test2()">
<script language="javascript">
function test1(){
alert('test1');
}
function test2(){
alert('here');
}
//document.body.attachEvent('onresize', test1);
window.attachEvent('onresize', test1);
</script>
</body>
</html>
使用document.body绑定onresize()方法无效:
document.body.attachEvent('onresize', test1);
1、要么使用onresize属性声明:
<body onresize="test2()">
2、要么使用window对象:
window.attachEvent('onresize', test1);
分享到:
相关推荐
document.all.topmsg.style.left=document.body.scrollLeft+document.body.clientWidth/2-document.all.topmsg.offsetWidth/2 document.all.topmsg.style.top=document.body.scrollTop+document.body.clientHeight-...
<!... 跳动的小球 *{margin:0;... document.body.appendChild(div); setTimeout(()=>{ document.body.removeChild(div); div = null; },1000) } })(); </body> </html>
方法一:在标签上加入 onLoad=”” onResize=”” 方法 写上对应的方法即可 方法二:[removed]=function(){///…..} 在方法里面写上对应的代码即可 着两种方法基本都可以解决问题。 [removed] function adjust...
浅谈javascript属性onresize //获取屏幕宽度并动态赋值 ...else if ((document.body) && (document.body.clientWidth)) winWidth = document.body.clientWidth; //获取窗口高度 if (window.innerHeigh
window.onresize=regenerate",400)}window.onload=regenerate2if (document.all){document.write(‘‘)themenu=document.all.slidemenubar2.stylerightboundary=0leftboundary=-150}else{themenu=document....
document.body.appendChild(this.canvas); window.addEventListener("resize", () => this.onResize()); this.onResize(); this.updateBound = this.update.bind(this); requestAnimationFrame(this....
解决方案: 代码如下:// IE浏览器下将onresize事件放在div上if(navigator.userAgent && navigator.userAgent.toLowerCase().indexOf(“msie”)>-1){ document.body[removed] = ‘<div onresize=”...
在b/s开发中经常用到的javaScript技术整理 一、验证类 1、数字验证内 1.1 整数 1.2 大于0的整数 (用于传来的ID的验证) ... 4.3 判断字符由字母和数字,... var all = eval(\"document.hrong.\"+ str); if ...
简单的div 该模块为您的演示和原型启动和运行提供了一个非常简单的 div 元素。 非常适合与 Beefy 一起使用。 例子 var easyDiv = require ( 'easy-div' ) ;... document . body ) ; 请参阅demo/demo.js了解更多用
var contentsHeight = document.body.clientHeight; var buttonsHeight = document.getElementById( "buttons" ).offsetHeight; var head1Height = document.getElementById( "head1" ).offsetHeight; var head2...
charset=gb2312" /> <title>test</title><br></head><br><body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0"> <table height=1000> <tr><td>dddd</td></tr> </table> </body>...
onresize = sP.resize; <SPAN class=spanclass style="DISPLAY: none"> <script>document.write("<img src=http://count5.pconline.com.cn/newcount/count.php?channel=135&screen="+screen.width+"*" +screen....
onresize=MM_reloadPage; }} else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload(); } MM_reloadPage(true); //--> <!-- .url { font-weight: bold; color: #666666; ...
示例描述:学习JavaScript中的document对象。 8.1.html 得到文档锚点对象数组。 8.2.html 获取并设置cookie信息。 8.3.html 获取文档标记的数组及相关操作。 8.4.html 获取location对象的属性值并...