Re: Dom api - differences in browser

Preetha,

You are likely trying to access a TextNode object that does not exist in 
your document. In order to cover the case, please try the following:

newcell.innerHTML = taskColl[i].childNodes[j].textContent || 
taskColl[i].childNodes[j].text;

For your information, there are mainly two versions of DOM implemented 
in browsers - Levels 2/3 (in Gecko-, Presto-, and Webkit-based) and 
Level 0 (Trident-based).
You may refer for the specification of DOM Levels 2/3 (implemented in 
other than Internet Explorer browsers) to the W3C website 
http://www.w3.org/ and for the reference on DOM Level 0 (implemented in 
Internet Explorer) to the website of Microsoft 
http://msdn.microsoft.com/en-us/library/ms533050(VS.85).aspx

Also, it is better to ask this kind of questions on developer forums, 
such as http://www.stackoverflow.com or other.
If you asked this question there you would quickly get a reply on how to 
adjust your code and a recommendation to pick up a JavaScript library, 
for example jQuery which provides browser-agnostic APIs for DOM traversal.

Regards,
Sergey Ilinsky/



Preetha wrote:
>
> Hi,
>
>  
>
> I have a problem when using dom api , when executed in different browsers.
>
>  
>
> I have to check for the browser type before using the dom api. For 
> example the text property works with IE 6.0
>
> But does not work with fire fox 3. So I have to 
> taskColl[i].childNodes[j].childNodes[0].nodeValue to get the same value.
>
>  
>
> Is there any common method in which all the browsers read or common 
> api that can be applied across browser.Please help , this is one case 
> I have mentioned , there are lot many compatibility issues.
>
>  
>
>  if(document.all){
>
>                         newcell.innerHTML = 
> taskColl[i].childNodes[j].text;
>
>  }else{
>
>             newcell.innerHTML = 
> taskColl[i].childNodes[j].childNodes[0].nodeValue;
>
>  }                                                                                  
>
>
>  
>
> Advanca thanks and Regards,
>
> **R Preetha **
>
> *Sella Synergy India Ltd*
>
> *El Net IT park **| Taramani |  Chennai*
>
> *Mail : preetha.r@sella.it*
>
>  
>
>
>
> Le e-mail provenienti dalla * Sella Synergy India Private Ltd * sono 
> trasmesse in buona fede e non comportano alcun vincolo ne' creano 
> obblighi per la * Sella Synergy India Private Ltd * stessa, salvo che 
> cio' non sia espressamente previsto da un precedente accordo.
> Questa e-mail e' confidenziale. Qualora l'avesse ricevuta per errore, 
> La preghiamo di comunicarne via e-mail la ricezione al mittente e di 
> distruggerne il contenuto. La informiamo inoltre che l'utilizzo non 
> autorizzato del messaggio o dei suoi allegati potrebbe costituire reato.
> Grazie per la collaborazione.
>
> E-mails from* Sella Synergy India Ltd Private * are sent in good faith 
> but they are neither binding on the * Sella Synergy India Private Ltd 
> * nor to be understood as creating any obligation on its part except 
> where provided for an agreement.
> This e-mail is confidential. If you have received it by mistake, 
> please inform the sender by reply e-mail and delete it from your 
> system. Please also note that the unauthorized disclosure or use of 
> the message or any attachments could be an offence.
> Thank you for your cooperation. 

Received on Thursday, 23 July 2009 17:54:04 UTC