`

document.body is null

 
阅读更多

虽然body是JS中的DOM技术中所有浏览器支持的属性,但在我们的代码编写中,还是会碰到document.is null问题 

问题的原因很简单,是因为我们在body标签前就加载了js,此时还没有body元素

问题的解决办法就是把调用到document.body的JS代码移到body标签代码结束之后。

转载地址:http://bestchenwu.iteye.com/blog/1231956

分享到:
评论

相关推荐

    jqzoom放大镜插件.zip

    position: "right" ,//zoomed div default position,offset position is to the right of the image lens:true, //zooming lens over the image,by default is 1; lensReset : false, imageOpacity: 0.2, title...

    表单验证大全

    function checkNum(str){return str.match(/\D/)==null} alert(checkNum("1232142141")) alert(checkNum("123214214a1")) // -->[removed] 2. 怎么判断是否是字符 ----------------------...

    107个常用javascript语句

    92.document.body.noWrap=true;防止链接文字折行. 93.变量名.charAt(第几位),取该变量的第几位的字符. 94."abc".charCodeAt(第几个),返回第几个字符的ASCii码值. 95.字符串连接:string.concat(string2),或用 =进行...

    javascript函数的解释

    92.document.body.noWrap=true;防止链接文字折行. 93.变量名.charAt(第几位),取该变量的第几位的字符. 94."abc".charCodeAt(第几个),返回第几个字符的ASCii码值. 95.字符串连接:string.concat(string2),或用+=进行...

    利用WebBrowser彻底解决Web打印问题(包括后台打印)

    frame.document.confirm("The document to print is not downloaded yet! Continue with printing?") )){execOnFinish();return;}var eventScope = printGetEventScope(frame);var focused = document.activeElement...

    出现问题a is defined高手帮忙

    cornerTopDiv: null, cornerRightDiv: null, cornerBottomDiv: null, cornerLeftDiv: null, mapPosition: null, outlineDiv: null, mapWidth: 0, mapHeight: 0, mapRatio: 0, startX:...

    js使用小技巧

    禁止选取<body oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return ...

    jquery需要的所有js文件

    e)}}),a(function(){var b=document.body,c=b.appendChild(c=document.createElement("div"));c.offsetHeight,a.extend(c.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0}),a.support.minHeight=c...

    .NET中实现客户端联动菜单 (无刷新)

    // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /**//// /// Required method for Designer support - do not modify /// the ...

    JavaScript Table行定位效果

    However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is null. 很简单,就是节点的父节点,看过dom都知道。 再看看比较容易区分的...

    在b/s开发中经常用到的javaScript技术整理

    function isTime(str) { var a = str.match(/^(\\d{1,2})(:)?(\\d{1,2})\\2(\\d{1,2})$/); if (a == null) {alert(\'输入的参数不是时间格式\'); return false;} if (a[1]>24 || a[3]>60 || a[4]>60) { ...

    新浪推荐浮动广告

    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>...

    js的日历时间控件

    do{if(b.tagName=="BODY"){break}a+=b.scrollTop||0;c+=b.scrollLeft||0;b=b.parentNode}while(b);return Element._returnOffset(c,a)},show:function(){if(!this.pickerActive){if(Control.DatePicker.activePicker...

    无限菜单之 xml+popup 版(IE5.5+)

    pops[degree].document.body.setAttribute("degree", degree); return pops[degree]; } CreatePopup(1); //创建一个2层的Popup家族 这个方法可以解决多个Popup共存的问题,只是如果要使用这个方法来实现...

    修改表结构的 asp C# 源代码

    + '\n' +' + (o.isNULL.checked?"NULL":"NOT NULL") + " \\n"' + '\n' +' + (o.fieldPK.checked?"PRIMARY KEY":"") + " "' + '\n' +' + (parseInt(o.fieldSeed.value)&&parseInt(o.fieldIncre.value)?"IDENTITY ...

    js验证表单 js验证表单

    function checkNum(str){return str.match(/\D/)==null} alert(checkNum("1232142141")) alert(checkNum("123214214a1")) // --></script> 2. 怎么判断是否是字符 --------------------------------------- ...

    图形jquery.gvChart-1.0.1.min.js

    frameWindow.document.execCommand('print', false, null)) { // document.execCommand returns false if it failed -http://stackoverflow.com/a/21336448/937891 frameWindow.print(); } } catch (e) { frame...

    Sortable前端框架

    fallbackOnBody: false, // Appends the cloned DOM Element into the Document's Body fallbackTolerance: 0, // Specify in pixels how far the mouse should move before it's considered as a drag. scroll:...

    servlet2.4doc

    Returns the object bound with the specified name in this session, or null if no object is bound under the name. getAttributeNames() - Method in interface javax.servlet.ServletContext Returns an ...

Global site tag (gtag.js) - Google Analytics