div.innerHTML in IE

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
pcoder
Forum Contributor
Posts: 230
Joined: Fri Nov 03, 2006 5:19 am

div.innerHTML in IE

Post 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
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: div.innerHTML in IE

Post 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.
User avatar
pcoder
Forum Contributor
Posts: 230
Joined: Fri Nov 03, 2006 5:19 am

Re: div.innerHTML in IE

Post 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.
:(
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: div.innerHTML in IE

Post 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.
Post Reply