children [" id"]。innerText - 不适用于netscape但使用资源管理器 [英] children["id"].innerText - does not work with netscape but with explorer
问题描述
我有一个适用于资源管理器但不适用于netscape的功能。
问题是第5行的功能。
1 fSetSelectedDay(myElement){
2 / *
3 ...
4 * /
5 var elementText = eval(myElement.children [" ; calDateText"]。innerText);
6 / *
7 ...
8 * /
9}
10<! - ... - >
11< td id = calCell onclick =''fSetSelectedDay(this)''>
12< font id =''calDateText''onclick =''fSetSelectedDay(this)''>
13< script> myMonth [w] [d]< / script>
14< / font>
15< / td>
16< ; - - ... - >
我需要一些支持。
非常感谢你。
Julia Peterwitz写道:我有一个适用于资源管理器的功能,但不适用于netscape。
问题是第5行的功能。 />
1 fSetSelectedDay(myElement){
2 / *
3 ...
4 * / /
5 var elementText = eval(myElement.children [" calDateText"]。innerText);
..innerText仅限IE,因此无法在NS中运行。使用
innerHTML。
eval不需要那里:
var elementText =
document.getElementById(myElement).children(''calDa teText'')。innerHTML;
[]也是IE-ism。
-
兰迪
机会有利于准备好的心灵
comp.lang.javascript常见问题 - http://jibbering.com/faq/
2004年5月5日星期三06:41:28 -0400,Randy Webb< hi ************ @ aol.com>
写道:
Julia Peterwitz写道:我有一个适用于资源管理器的功能,但不适用于netscape。
问题是第5行的功能。
1 fSetSelectedDay(myElement){
2 / *
3 ...
4 * /
5 var elementText = eval(myElement.children [" calDateText" ;]。innerText);
.innerText仅限IE,并且因此不适用于NS。改为使用
innerHTML。
那里不需要eval:
同意,但是......
var elementText =
document.getElementById(myElement).children(''calDa teText'')。innerHTML;
....有这一行有两个问题:
1)如果你看一下OP的HTML,你会发现myElement是一个
的引用元素,而不是id。
2)儿童财产是
a)一个集合,所以括号是正确的,
b)也是微软主义。
或许
var elementText = myElement.childNodes [''calDateText''] .innerHTML;
会更好(最好有功能检测)?
Mike
-
Michael Winter
M.******@blueyonder.co.inva 盖子(将.invalid替换为.uk以回复)
myElement.childNodes [''calDateText''] .innerHTML;
也不工作
(它既不适用于资源管理器也适用于netscape)
netscape的任何其他提议??
资源管理器再次解决方案:
myElement.children [ " calDateText"]。innerText;
***通过Developersdex发送 http://www.developersdex.com ***
不要只是参加USENET ......获得奖励!
I have a function that works with explorer but not with netscape.
The problem is the function at line 5.
1 fSetSelectedDay(myElement){
2 /*
3 ...
4 */
5 var elementText = eval(myElement.children["calDateText"].innerText);
6 /*
7 ...
8 */
9 }
10 <!-- ... -->
11 <td id=calCell onclick=''fSetSelectedDay(this)''>
12 <font id=''calDateText'' onclick=''fSetSelectedDay(this)''>
13 <script> myMonth[w][d] </script>
14 </font>
15 </td>
16 <!-- ... -->
I need some support for this.
Thank you very much.解决方案Julia Peterwitz wrote:I have a function that works with explorer but not with netscape.
The problem is the function at line 5.
1 fSetSelectedDay(myElement){
2 /*
3 ...
4 */
5 var elementText = eval(myElement.children["calDateText"].innerText);
..innerText is IE only, and as such is not going to work in NS. use
innerHTML instead.
eval is not needed there:
var elementText =
document.getElementById(myElement).children(''calDa teText'').innerHTML;
the [ ] are also an IE-ism.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
On Wed, 05 May 2004 06:41:28 -0400, Randy Webb <hi************@aol.com>
wrote:
Julia Peterwitz wrote:I have a function that works with explorer but not with netscape.
The problem is the function at line 5.
1 fSetSelectedDay(myElement){
2 /*
3 ...
4 */
5 var elementText = eval(myElement.children["calDateText"].innerText);
.innerText is IE only, and as such is not going to work in NS. use
innerHTML instead.
eval is not needed there:
Agreed, however...
var elementText =
document.getElementById(myElement).children(''calDa teText'').innerHTML;
....there are two problems with this line:
1) If you look at the OP''s HTML, you''ll see that myElement is a
reference to the element, not an id.
2) The children property is
a) a collection, so the brackets were correct,
b) also a Microsoft-ism.
Perhaps
var elementText = myElement.childNodes[ ''calDateText'' ].innerHTML;
would be better (preferably with feature detection)?
Mike
--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
myElement.childNodes[ ''calDateText'' ].innerHTML;
is also not working
(it neither works in explorer nor in netscape)
any other proposals for netscape??
solution for explorer again:
myElement.children["calDateText"].innerText;
*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!
这篇关于children [" id"]。innerText - 不适用于netscape但使用资源管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!