DOM的问题 [英] problems with DOM

查看:83
本文介绍了DOM的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在变量中保存图像的对象。

我正在使用Internet Explorer进行此操作,使用以下行没有问题:

oImage = node.childNodes(0).all [" pic"]


现在我想使用W3C标准,并认为我可以在这里使用它来获取我的对象:

oImage = node.childNodes(0).getElementById(" pic")

节点变量来自xsl文件:

。 ...

< div onclick =" window.event.cancelBubble = true; clickOnNode(this);"

....


我不明白!我尝试了很多变化并在网上搜索但我没有找到任何东西。

感谢您对此主题的每一点提示!问候,

Tim。

I want to save an object of an image in a variable.
I am doing this with the internet explorer with no problems using the following line:
oImage = node.childNodes(0).all["pic"]

Now I wanted to use the W3C-standard and thought I could get my object using this here:
oImage = node.childNodes(0).getElementById("pic")

The node variable is from an xsl file:
....
<div onclick="window.event.cancelBubble = true; clickOnNode(this);"
....

I don′t get it! I′ve tried a lot of variations and searched the net but I didn′t find anything.
Thanks for every little hint on this topic! Greetings,
Tim.

推荐答案




TimBücker写道:


Tim Bücker wrote:
我想在变量中保存图像的对象。
我正在使用Internet Explorer进行此操作,使用以下行没有问题:
oImage = node.childNodes(0).all [" pic"]
现在我想使用W3C标准,并认为我可以在这里使用它来获取我的对象:
oImage = node。 childNodes(0).getElementById(" pic")
I want to save an object of an image in a variable.
I am doing this with the internet explorer with no problems using the following line:
oImage = node.childNodes(0).all["pic"]

Now I wanted to use the W3C-standard and thought I could get my object using this here:
oImage = node.childNodes(0).getElementById("pic")




使用

node.ownerDocument.getElementById(" pic")

-


Martin Honnen
http://JavaScript.FAQTs.com/



Use
node.ownerDocument.getElementById("pic")
--

Martin Honnen
http://JavaScript.FAQTs.com/


感谢您的快速回答,但遗憾的是问题仍未解决。

它仍然是相同的 - 忽略活动节点始终是

文件中的第一个被选中(我想更改菜单的图标,无论他们是否选择了
)!


是否需要更多信息?关于这个

主题的网上任何资源?更多想法?我越来越绝望......


但是再次感谢回答,

Tim。


Martin Honnen <毫安******* @ yahoo.de> schrieb im Newsbeitrag新闻:3f ******** @ olaf.komtel.net ...
Thanks for the quick answer but unfortunately the problem is not solved.
It is still the same - ignoring the active node always the first one in the
document gets selected (I want to change icons for a menu whether they
are selected or not)!

Is more information needed? Any resources on the web concerning this
topic? More ideas? I am getting more and more desperate...

But thanks again for answering,
Tim.

"Martin Honnen" <ma*******@yahoo.de> schrieb im Newsbeitrag news:3f********@olaf.komtel.net...


TimBücker写道:


Tim Bücker wrote:
我想在变量中保存图像的对象。
我使用Internet Explorer在使用以下行时没有问题:
oImage = node.childNodes(0) .all [" pic"]

现在我想使用W3C标准,并认为我可以在这里使用它来获取我的对象:
oImage = node.childNodes(0).getElementById (" pic")
I want to save an object of an image in a variable.
I am doing this with the internet explorer with no problems using the following line:
oImage = node.childNodes(0).all["pic"]

Now I wanted to use the W3C-standard and thought I could get my object using this here:
oImage = node.childNodes(0).getElementById("pic")



使用
node.ownerDocument.getElementById(" pic")
-

Martin Honnen
http://JavaScript.FAQTs.com/



" DIV via DOM"不会暴露getElementById()和getElementByName()

方法,至少不会暴露在IE中。


如果你真的想让你的生活变得复杂尽可能;-)然后

使用类似的东西:

myNode.childNodes(0).getElementsByTagName(''IMG'')[0] .src = newSrc; <为了使它更有趣,你实际上可以首先删除检索到的图像节点,

创建一个带有另一个src属性的新节点并将其插回。


最后一个愚蠢的问题:为什么不使用全球document.images [i]

集合?这是完全正确的3W认可的合成器,如果你担心它的价格是b $ b。

"DIV via DOM" doesn''t expose getElementById() neither getElementByName()
methods, at least not in IE.

If you really want to keep your life as complicated as possible ;-) then
use something like:
myNode.childNodes(0).getElementsByTagName(''IMG'')[0].src = newSrc;

To spice it up, you actually can remove first the retrieved image node,
create a new one with another src attribute and insert it back.

Last stupid question: why not use the global document.images[i]
collection? It''s totally correct 3W-approved syntacs, if you are worried
about it.


这篇关于DOM的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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