简体   繁体   English

document.body为null

[英]document.body is null

I've got a page where I'm using Mootools 1.2.4 and MediaboxAdvanced as a lightbox. 我有一个页面使用Mootools 1.2.4和MediaboxAdvanced作为灯箱。 I can't seem to get the thing working because of a particular javascript error 由于特定的javascript错误,我似乎无法正常工作

document.body is null document.body为null

at the initialization of Mediabox: 在Mediabox初始化时:

$(document.body).adopt(
     $$([
          overlay = new Element("div", {id: "mbOverlay"}).addEvent("click", close),
          center = new Element("div", {id: "mbCenter"})
     ]).setStyle("display", "none")
); 

The page is here . 页面在这里 If yo uclick on the guy's name, picture, or the More Info button on the bottom right, it is supposed to launch the Mediabox. 如果您单击该人的名字,图片或右下角的“更多信息”按钮,则应该启动Mediabox。 Via Firebug, I have confirmed that the CSS is loading, mootools is loading, and the Mediabox script is loading; 通过Firebug,我已确认正在加载CSS,正在加载mootools和正在加载Mediabox脚本; all the paths to images and everything are correct as well. 图像的所有路径以及所有内容都正确。

Any ideas? 有任何想法吗?

You may only be able to use $ on an element returned from getElementById. 您可能只能在$ getElementById返回的元素上使用$。 A simple workaround is to instead use $$. 一个简单的解决方法是改为使用$$。

$$('body')[0].adopt...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM