可以看到NS的财产 [英] Can see property in NS

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

问题描述

全部好,


我为每个选项在select标签中创建了一个已关闭的属性。

然后为该属性赋值为0或者1.

然后我在JS脚本中评估这个属性

当我在IE中执行此操作时,我得到正确的值0或1

但是当我在NS中尝试完全相同的东西时,我会得到一个未定义的消息

。我使用NS DOM inspectore跟踪这个。在DOM检查器中,我可以使用正确的值查看封闭属性
。它坐落在价值属性

下面的同一水平上。它就在那里。

为什么在NS运行时封闭的属性是未定义的,但在IE中它的工作原理

这是我的JS:


函数有效(op)

{

var amount = document.sclaim.estout.value;

var sel = 0 < ($ var $ 0; i< op.options.length; i ++)

if(op.options [i] .selected){

sel = i;

var cl = op.options [i] .closed;

var status = op.options [i] .text;

{alert(" Not invalid" + cl);}

}

}


谢谢

Robert

HI all,

I created a property callsed closed with in a select tag for each option.
The property is then assigned a value of 0 or 1.
I then evaluate this property in a JS script
When I do this in IE, I get the correct value either 0 or 1
But when I try the exact same thing in NS I get, an undefined message
instead. I used NS DOM inspectore to trace this. In the DOM inspector I can
see the closed property with the correct values. It is sitting right beneath
the value property, on the same level. SO it is there.
How come when run in NS the closed property is undefined but in IE it works
This is my JS:

function valid (op)
{
var amount = document.sclaim.estout.value;
var sel = 0
for (var i = 0; i < op.options.length; i++)
if (op.options[i].selected){
sel = i;
var cl = op.options[i].closed;
var status = op.options[i].text;
{alert("Not valid "+cl);}
}
}

Thanks
Robert

推荐答案

Robert Bravery写道:
Robert Bravery wrote:
HI all,
<我在每个选项的select标签中创建了一个callsed属性。
然后为该属性赋值为0或1.
然后我在JS脚本中评估此属性当我在IE中执行此操作时,我得到正确的值0或1
但是当我尝试完全相同的东西时NS我得到了一个未定义的消息
。我使用NS DOM inspectore跟踪这个。在DOM检查器中,我可以使用正确的值查看已关闭的属性。它坐落在价值属性的正下方,在同一水平上。它就在那里。


它存在于DOM树中。它不存在 - 在DOM界面中。

这是两个混合的常见错误,因为IE对自定义属性的处理松散。假设您有一个div标签,例如:

< div id =" myDIV"名称= QUOT; myDIV" foo =" bar">内容< / div>

收到此源字符串后,HTML解析器在DOM树中创建

元素节点DIV,其属性节点ID =" myDIV",NAME =" myDIV",

FOO =" bar"。你可以打开DOM Inspector并查看所有这些节点。

但是你需要在脚本中引用div元素,比如说

var d = document.getElementById(" ; myDIV");

你没有得到元素节点:你正在获取脚本/ DOM

这个元素的接口/。并且标准兼容的UA'在这个

接口中仅显示给定接口/的属性/。说DIV

元素可以有ID,所以这个属性作为对象属性公开。在

的同时,DIV元素不能具有属性NAME和FOO,因此这些

属性不会被用作对象属性。这就产生了你刚刚描述的有趣的

情况:然后你看到树上的东西但是

没看到在你的脚本中。

幸运的是你有直接访问DOM树的工具:hasAttribute /

getAttribute / setAttribute。因此规则是:如果您在元素标记中使用自定义

属性,为了初始访问它们,您使用

getAttribute。默认情况下允许给定元素

的属性可以立即作为对象属性访问。

var cl = op.options [i] .closed;
HI all,

I created a property callsed closed with in a select tag for each option.
The property is then assigned a value of 0 or 1.
I then evaluate this property in a JS script
When I do this in IE, I get the correct value either 0 or 1
But when I try the exact same thing in NS I get, an undefined message
instead. I used NS DOM inspectore to trace this. In the DOM inspector I can
see the closed property with the correct values. It is sitting right beneath
the value property, on the same level. SO it is there.
It is there - in the DOM Tree. It is not there - in the DOM Interface.
That''s a common mistake to mix both, because of IE''s loose handling of
custom attributes. Let''s say you have a div tag like:
<div id="myDIV" name="myDIV" foo="bar">Content</div>
Upon receiving this source string HTML parser creates in DOM Tree
element node DIV with attribute nodes ID="myDIV", NAME="myDIV",
FOO="bar". You can open DOM Inspector and see all these nodes.
But then you require a reference to the div element in your script, say
var d = document.getElementById("myDIV");
you are not getting element node: you are getting scriptable /DOM
Interface/ for this element. And standard-compliant UA''s expose in this
interface only property /defined for the given interface/. Say DIV
element can have ID so this attribute is exposed as object property. At
the same time DIV element cannot have attributes NAME and FOO, so these
attributes are not used as object property. That creates that funny
situation you just described: then you "see" something in the tree but
"don''t see" in your script.
Lucky you have tools for direct DOM Tree access: hasAttribute /
getAttribute / setAttribute. So the rule is: if you are using custom
attribute in element tag, in order to initially access them you use
getAttribute. The attributes allowed by default for the given element
are accessible right away as object properties.
var cl = op.options[i].closed;




var cl = op.options [i] .getAttribute(" closed");



var cl = op.options[i].getAttribute("closed");


Robert Bravery写道:
Robert Bravery wrote:
我为每个选项创建了一个已调用的属性,其中包含一个选择标记



没有证据证明你在这里提供的方式和地点。从您的

措辞听起来更像是为您的

OPTION元素定义了一个自定义属性。


< snip>为什么在NS中运行封闭的属性是未定义的
但在IE中它
I created a property callsed closed with in a select tag
for each option.
No evidence of how or where you did that is presented here. From your
wording it sounds more like you have defined a custom attribute for your
OPTION elements.

<snip> How come when run in NS the closed property is undefined
but in IE it



< snip>


所以你是问为什么做一些你没有表现出来的东西没有

有你想要的结果吗?


Richard。


<snip>

So you are asking why doing something that you have not shown does not
have the results you expect it to have?

Richard.


HI VK,

很棒。谢谢你的解释。现在你已经完全理解了

正确解释了它。

你的建议也很完美


谢谢

Robert


" VK" < SC ********** @ yahoo.com>在消息中写道

新闻:11 ********************** @ i39g2000cwa.googlegr oups.com ...
HI VK,
Brilliant. Thanks for the explanations. makes perfect sense now that you
explained it correctly.
You suggestion also works perfectly

Thanks
Robert

"VK" <sc**********@yahoo.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
Robert Bravery写道:
Robert Bravery wrote:
HI all,

我在每个
选项的select标签中创建了一个callsed属性。然后为该属性赋值为0或1.
然后我在JS脚本中评估此属性
当我在IE中执行此操作时,我得到正确的值0或1
但是当我在NS中尝试完全相同的东西时,我得到一个未定义的消息
。我使用NS DOM inspectore跟踪这个。在DOM检查器中,I
可以使用正确的值查看已关闭的属性。它位于价值属性下面的
,在同一水平上。它就在那里。
HI all,

I created a property callsed closed with in a select tag for each option. The property is then assigned a value of 0 or 1.
I then evaluate this property in a JS script
When I do this in IE, I get the correct value either 0 or 1
But when I try the exact same thing in NS I get, an undefined message
instead. I used NS DOM inspectore to trace this. In the DOM inspector I can see the closed property with the correct values. It is sitting right beneath the value property, on the same level. SO it is there.



它就在那里 - 在DOM树中。它不在那里 - 在DOM界面中。
这是混合两者的常见错误,因为IE对自定义属性的处理松散。假设您有一个div标签,例如:
< div id =" myDIV"名称= QUOT; myDIV" foo =" bar"> Content< / div>
收到此源字符串后,HTML解析器在DOM Tree
元素节点DIV中创建属性节点ID =" myDIV",NAME =" myDIV" ;,
FOO =bar。你可以打开DOM Inspector并查看所有这些节点。
但是你需要在脚本中引用div元素,比如
var d = document.getElementById(" myDIV");
你没有获得元素节点:你正在获得这个元素的脚本/ DOM
接口/。并且符合标准的UA在此
接口中仅显示给定接口/定义的属性。假设DIV
元素可以具有ID,因此该属性作为对象属性公开。在同一时间DIV元素不能具有属性NAME和FOO,因此这些属性不用作对象属性。这就产生了你刚刚描述的那种有趣的情况:然后你看到树上的东西,但是没有看到在你的脚本中。
很幸运,你有直接访问DOM树的工具:hasAttribute /
getAttribute / setAttribute。因此规则是:如果您在元素标记中使用自定义
属性,为了初始访问它们,您使用
getAttribute。默认情况下允许给定元素的属性
可以立即作为对象属性访问。



It is there - in the DOM Tree. It is not there - in the DOM Interface.
That''s a common mistake to mix both, because of IE''s loose handling of
custom attributes. Let''s say you have a div tag like:
<div id="myDIV" name="myDIV" foo="bar">Content</div>
Upon receiving this source string HTML parser creates in DOM Tree
element node DIV with attribute nodes ID="myDIV", NAME="myDIV",
FOO="bar". You can open DOM Inspector and see all these nodes.
But then you require a reference to the div element in your script, say
var d = document.getElementById("myDIV");
you are not getting element node: you are getting scriptable /DOM
Interface/ for this element. And standard-compliant UA''s expose in this
interface only property /defined for the given interface/. Say DIV
element can have ID so this attribute is exposed as object property. At
the same time DIV element cannot have attributes NAME and FOO, so these
attributes are not used as object property. That creates that funny
situation you just described: then you "see" something in the tree but
"don''t see" in your script.
Lucky you have tools for direct DOM Tree access: hasAttribute /
getAttribute / setAttribute. So the rule is: if you are using custom
attribute in element tag, in order to initially access them you use
getAttribute. The attributes allowed by default for the given element
are accessible right away as object properties.

var cl = op.options [i] .closed;
var cl = op.options[i].closed;



var cl = op.options [i] .getAttribute(" closed");



var cl = op.options[i].getAttribute("closed");



这篇关于可以看到NS的财产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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