• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to eliminate the diffrence between firefox and ie about this problem

 
lei liu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to eliminate the diffrence between firefox and ie about this problem

the code below:

var template = '<div class="fileheadbg">'
+'<div class="filename"><a href="/" >__name__</a></div>'
+'<div class="fileimg"><img src="images/property.gif" width="9" height="10" hspace="0" align="middle"></div>'
+'<div class="fileimg"><img src="images/download.gif" width="9" height="10" align="middle"></div>'
+'</div>';


the above variable is store the text:

<div class="fileheadbg">
<div class="filename" id="filename__id__"><a href="/" >__name__</a></div>
<div class="fileimg" id="property__id__"><img src="images/property.gif" width="9" height="10" hspace="0" align="middle"></div>
<div class="fileimg" id="download__id__"><img src="images/download.gif" width="9" height="10" align="middle"></div>
</div>


when i do this:

var elem = document.createElement('div');
elem.innerHTML = template;
alert(elem.childNodes.length);
//outputs
//in IE: 1
//in FireFox: 3

why like this???

now my target is after set the elem.innerHTML, I 'll get the reference of the div with id='property__id__' instantly
how can i complete the mission???
I think I can hard code the :
var proElem = elem.childNodes[0].childNodes[2]; //IE only
but FireFox not work,how to ensure the compatible??

Please Help me ,and I'm not good at english, thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65123
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"digital ghost",

There aren't may rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
lei liu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok ,I have modify the nick name to my real name ,sorry!
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need to append the div to the page, then you can look at its children.

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic