Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Mar 2004
    Posts
    138
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using innerHTML in IE

    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:

    Code:
    function col(id)
    {
    var tabToChange = document.getElementById(id);
    tabToChange.innerHTML = "";
    }
    This is how I call it:

    Code:
    <a href="#" onclick="javascript:col('tableid');"><img src="src.ext"></a>
    What am I doing wrong here?

    Thanks,
    Matt
    Last edited by MattJakel; 07-14-2004 at 10:51 PM.
    Linux Distribution Download: $0
    OpenOffice.org: $0
    Mozilla: $0
    Gaim: $0
    GIMP: $0
    Converting to Open Source: Priceless

  • #2
    Regular Coder
    Join Date
    Mar 2004
    Posts
    138
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:

    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?

    Thanks,
    Matt
    Linux Distribution Download: $0
    OpenOffice.org: $0
    Mozilla: $0
    Gaim: $0
    GIMP: $0
    Converting to Open Source: Priceless

  • #3
    New Coder
    Join Date
    Nov 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    New Coder
    Join Date
    Nov 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <table>
    <tr id="one"><td>one</td></tr>
    </table>
    <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.

  • #5
    Regular Coder
    Join Date
    Mar 2004
    Posts
    138
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

    Thanks,
    Matt
    Linux Distribution Download: $0
    OpenOffice.org: $0
    Mozilla: $0
    Gaim: $0
    GIMP: $0
    Converting to Open Source: Priceless

  • #6
    Regular Coder
    Join Date
    Jun 2004
    Posts
    565
    Thanks
    0
    Thanked 18 Times in 18 Posts
    If you set the elements display-attribute to 'none' the element should take up no space on the site anymore, e.g.:
    Code:
    <a href="javascript:document.getElementById('tableid').style.display = 'none'"><img src="src.ext"></a>
    dumpfi

  • #7
    Regular Coder
    Join Date
    Mar 2004
    Posts
    138
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Spy and dump! That style.display property got it!

    Matt
    Linux Distribution Download: $0
    OpenOffice.org: $0
    Mozilla: $0
    Gaim: $0
    GIMP: $0
    Converting to Open Source: Priceless


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •