File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes IE doesn't seem to reflect updated document object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "IE doesn Watch "IE doesn New topic
Author

IE doesn't seem to reflect updated document object

Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1873
Hi all,

I am trying to insert a content dynamically via innerHTML thing in DIV tag. The content is reflected as soon as I call BUT when I try to get that data back via method it doesn't give me the elements which I inserted. Here is the example code I have,



NOTE: I had to edit on click method name here to be onClick1 to avoid the HTML content error I was getting while doing the post Please change it to be right one if you want to test it.

Does anybody have some clue what is happening here?

The reason I want to do this functionality is -- I have some HTML content which I have to allow users load in my page just by putting it in textarea and my code should identify all that is loaded in it BUT I want to avoid "parsing" myself so I am piggybacking on HTML DOM itself by first inserting that HTML data specified in textarea to the hidden DIV tag and then doing parsing based on method.

Can somebody throw some light on this? Is there a workaround or other way to achieve what I want to do? Please let me know if I sound unclear.

Regards
Maulin
[ November 15, 2006: Message edited by: Maulin Vasavada ]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
div does not have a name attribute, so that might b the start of your troubles.

Have you looked into getElementsByTagName()

Eric
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1873
Hi Eric

Thanks much for the guidelines. You are right, div doesn't have name attribute as such. Probably only form fields are supposed to have it.

The issue is I can't use ID attribute as that would add much complexity in my code for no reason.

Also, I noticed that getElementsByTagName doesn't work properly in Firefox. I got the div element array but I can't check the name attribute on it in Firefox. IE works fine in that case.

So here is how I am getting around the problem now,




This above code works for IE and firefox both. I don't know how long it would work though as still I end up using name attribute in case of IE (in the for loop where I prepare the array of elements) BUT for now it seems it should work. I don't know if this would work in IE7 too.

Thanks again for your help.

Regards,
Maulin
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: IE doesn't seem to reflect updated document object