View Full Version : Using innerHTML in IE
07-14-2004, 11:44 PM
EDIT: I found the problem. Apparently innerHTML in IE only works with <td>s and not <table>s.
Nothing I write in JS ever works in IE after i get it to work in Mozilla lol. I have this function that is called when an image is clicked and makes everything inside of a table disappear. Here's the code:
var tabToChange = document.getElementById(id);
tabToChange.innerHTML = "";
This is how I call it:
What am I doing wrong here?
07-15-2004, 12:38 AM
Ok, I'm having a new problem, this time with a regular expression. Once again it works in everything but IE. Here's the code:
var thing = tabtochange.innerHTML;
toUncomment = new String (thing);
toUncommentres = toUncomment.replace(/<!--jsinsert/, "");
toUncommentdos = new String (toUncommentres);
tabtochange.innerHTML = toUncommentdos.replace(/jsinsert-->/, "");
What am I doing wrong?
07-15-2004, 12:55 AM
They are going to ask you to post different questions separately .
As for your innerHTML question. A <table> does not have an innerHTML property. <table> has <tr> children, which have <td> children which have textNode children or a innerHTML.
Mozilla's ability to do what you want is suspect to say the least.
07-15-2004, 01:01 AM
<A href="#" onClick="document.getElementById('one').style.visibility='hidden'">one</A>
Here is the easiest way to hide the table data. Unless you want to code a loop to remove the elements.
07-15-2004, 01:13 AM
The problem with that is that I need the space where it was to be used by something else while it's hidden, so the only way I know to do that is to set the innerHTML to "" or (as I decided to change it to) placing comment tags around the innerHTML, which is why I need the regular expressions to work.
07-15-2004, 01:37 AM
If you set the elements display-attribute to 'none' the element should take up no space on the site anymore, e.g.:
07-15-2004, 02:24 AM
Thanks Spy and dump! That style.display property got it!
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.