Page 1 of 1

div.innerHTML in IE

Posted: Sun Jul 26, 2009 5:24 am
by pcoder
I have this content in div called "divPrimary".

Code: Select all

 
<div id="divPrimary">
        <table>
        <tr>
             <th> Name:</th>
            <th><input type="text" [b]id="CPCONTACT_PERSON_NAME" name="CPCONTACT_PERSON_NAME"[/b] value="" /></th>
        </tr>
        <tr>
            <th>Designation:</th>
            <th><input type="text" id="CPCONTACT_PERSON_DESIGNATION" name="CPCONTACT_PERSON_DESIGNATION" value="" /></th>
        </tr>
 
        </table>   
    </div>
 
And I am trying to copy this div value to a new one using javascript. Like this:

Code: Select all

 
 var contents = document.getElementById(sdiv).innerHTML;
 
The problem is when I check the contents value in FF. It gives exactly like the content in HTML above. But in IE, It does not give the double quotes("). i.e.
Contents is like:

Code: Select all

 
 <table>
        <tr>
             <th> Name:</th>
            <th><input [b]id=CPCONTACT_PERSON_NAME name=CPCONTACT_PERSON_NAME[/b] /></th>
       </tr>
       ...
</table>
 
I could not figure it out, Why IE is not giving the exact values from HTML content.
Hope to get some reason from you guys.

Thanks

Re: div.innerHTML in IE

Posted: Sun Jul 26, 2009 10:45 am
by kaszu
Why IE is not giving the exact values from HTML content
Because it's IE. I don't think there is anything you can do about it.

Re: div.innerHTML in IE

Posted: Sun Jul 26, 2009 11:58 pm
by pcoder
Thanks kaszu for your reply.
Yeh, you are correct. It's IE.
For this I have created a new thread in Regular Expression. Now I want to replace this using regular expression.
In FF, It works perfectly. I am writing this only for IE.
We have to waste so much of time for IE.
:(

Re: div.innerHTML in IE

Posted: Tue Aug 04, 2009 1:40 am
by JAB Creations
To move existing XML from one element to another use appendChild.

Read more here...
https://developer.mozilla.org/En/DOM/Node.appendChild

...and don't use innerHTML ever unless you strictly intend to only write to an element.