JS中的可重用图像缓存=> NS_ERROR_DOM_HIERARCHY_REQUEST_ERR [英] Reusable Image Cache in JS => NS_ERROR_DOM_HIERARCHY_REQUEST_ERR

查看:62
本文介绍了JS中的可重用图像缓存=> NS_ERROR_DOM_HIERARCHY_REQUEST_ERR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(Mac 10.4.6,Firefox / 1.5.0.3 Mozilla / 5.0(Macintosh; U; PPC Mac OS X

Mach-O; fr; rv:1.8.0.3)Gecko / 20060426)


我正在尝试在JS中设置可重用的图像缓存(根据
http://www.devx.com/webdev/Article/20947


为了调查来自组中图像加载的事件

容器,似乎需要执行以下功能,

ImagePair(文件)。

不幸的是Firefox javascript检查提到这个

函数的错误:

=> document.appendChild(this.image);


有没有人有关于它的提示?


------ JS函数 - -------------

函数ImagePair(_file){

// ImagePair对象的目的是跟踪图像和

标识它的文件;

//我们这样做是因为图像的src属性将回读为

uuencoded如果被询问,//意思是,要查看缓存中是否存在特定的

图像,我们需要再次使用uuencode

//。以未编码的形式存储路径似乎更容易,

以及与之关联的图像。


this.file = _file;

this.image = new Image();


//将图像添加到文档中;如果你没有,readystatechange

//事件不知道它们起源于何处,这意味着

event.srcElement将为null

document.appendChild(this.image);

}


-----------错误信息

Erreur *:未捕获的异常:[例外...节点不能插入

层次结构中的指定点代码:3 nsresult:" 0x80530003

(NS_ERROR_DOM_HIERARCHY_REQUEST_ERR)" location:

" http://www.ecolabs.loc/scripts_js/load-image.js Line:82"]

(Mac 10.4.6 , Firefox/1.5.0.3 Mozilla/5.0 (Macintosh; U; PPC Mac OS X
Mach-O; fr; rv:1.8.0.3) Gecko/20060426 )

I am trying to setup a Reusable Image Cache in JS ( as per
http://www.devx.com/webdev/Article/20947 )

In order to o survey the events from image loading in a group
container, It seems necessary to perform the following function,
ImagePair(file) .
Unfortunatly Firefox javascript checking mentions an error with this
function :
=> document.appendChild(this.image);

does anyone have a hint about it ?

------ JS function --------------
function ImagePair( _file ) {
// The ImagePair object''s purpose is to keep track of the image and
the file that identifies it;
// we do this because the image''s src attribute will read back as
uuencoded if interrogated, // meaning that, to see if a particular
image exists in the cache, we need to uuencode
// again. It seems easier just to store the path in unencoded form,
along with the image //associated with it.

this.file = _file;
this.image = new Image();

// Add the image to the document; if you don''t, readystatechange
// events won''t know where they originated, meaning that
event.srcElement will be null
document.appendChild(this.image);
}

----------- error message
Erreur*: uncaught exception: [Exception... "Node cannot be inserted at
the specified point in the hierarchy" code: "3" nsresult: "0x80530003
(NS_ERROR_DOM_HIERARCHY_REQUEST_ERR)" location:
"http://www.ecolabs.loc/scripts_js/load-image.js Line: 82"]

推荐答案

Josselin写道:

< snip>
Josselin wrote:
<snip>
=> document.appendChild(this.image);

有没有人对此有所暗示?
< snip> Erreur:未被捕获的异常:[例外......节点不能插入层次结构中的指定点
=> document.appendChild(this.image);

does anyone have a hint about it ? <snip> Erreur : uncaught exception: [Exception... "Node cannot
be inserted at the specified point in the hierarchy"



< snip>


有问题的层次结构是DOM的树状层次结构。

文档位于DOM的绝对根和

中的(x)HTML元素,标记是文档的后代,最外面的

包含元素(通常为http)作为文档的直接子元素和

所有其他元素的HTML元素的正常性。


有限制在这个

树状结构和IMG元素中可能出现的各种元素必须至少是BODY元素的后代。您试图在与HTML元素相同的级别插入IMG,这在(x)HTML

文档结构方面没有意义,还有一些浏览器会在回复时产生错误。


Richard。


<snip>

The hierarchy in question is the tree-like hierarchy of the DOM. The
document is at the absolute root of the DOM and the (x)HTML elements in
the mark-up are descendants of the document, with the outermost
containing element (usually http) as a direct child of the document and
all other elements decentness of the HTML element.

There are restrictions on where various elements may appear in this
tree-like structure and IMG elements must be, at minimum, descendants of
the BODY element. You are trying to insert an IMG at the same level as
the HTML element, which does not make sense in terms of an (x)HTML
document structure, and some browsers will generate errors in response.

Richard.


Richard Cornford写道:

< snip>
Richard Cornford wrote:
<snip>
...,最外层包含元素
(通常是http)作为文件的直接子元素
^^^^和HTML的所有其他元素的正常性元素。
... , with the outermost containing element
(usually http) as a direct child of the document ^^^^ and all other elements decentness of the HTML element.



< snip>


应该是......最外层包含元素(通常是html)

...."


即html元素是(x)HTML文档中最外层的元素。

所有其他元素都是它的后代,其直接的孩子是头部和身体元素。 (处理说明,例如DOCTYPE

和注释在此上下文中是严格的节点.DOCTYPE可能是html元素的兄弟姐妹,如果它表示为

DOM。文本节点,代表非重要的空白区域,也可能是
显示为文档的直接子节点,因此html的兄弟姐妹

元素。


Richard。


<snip>

That should have been "... outermost containing element (usually html)
...."

i.e. The html element is the outermost element in an (x)HTML document.
All other elements are its descendants, with its direct children being
the head and body elements. (Processing instructions, such as DOCTYPE
and comments are strictly Nodes in this context. DOCTYPE may be a
(preceding) sibling of the html element, if it is represented in the
DOM. Text nodes, representing non-significant white space, may also
appear as direct children of the document, and so siblings of the html
element).

Richard.


Richard Cornford写道:
Richard Cornford wrote:
html元素是(x)HTML文档中最外层的元素。
所有其他元素都是它的后代,其直接孩子是头部和身体元素。
The html element is the outermost element in an (x)HTML document.
All other elements are its descendants, with its direct children being
the head and body elements.




至少对于Firefox来说并不完全正确(在Opera上完全不用测试
)。在Firefox中,HTML就像其他任何一个容器一样,你可以添加说图像和div'。试试

html {

宽度:100%;

身高:100%;

背景色:# DDD;

}

身体{

宽度:75%;

背景颜色:#FFF; < br $>
}


现在加上说< img src = ...>介于< / body>之间和< / html> ;.


IE在这种情况下进行自动树校正(因此< body>容器
仍然使用
)。我不知道它是否正确阅读规格

或渲染错误 - 但应该提及。



It is not exactly true at least for Firefox (keep missing to test in
full on Opera). In Firefox HTML is a container as any other where you
can add say images and div''s. Try
html {
width:100%;
height:100%;
background-color:#DDD;
}
body {
width:75%;
background-color:#FFF;
}

and now add say <img src=...> between </body> and </html>.

IE does automatical tree correction in such case (so <body> container
is still used instead). I don''t know if it''s a proper reading of specs
or a rendering bug - but should be mentioned.


这篇关于JS中的可重用图像缓存=&gt; NS_ERROR_DOM_HIERARCHY_REQUEST_ERR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆