Topic awaiting preservation: I have a question about innerHTML and DOM (Page 1 of 1) |
|
---|---|
Obsessive-Compulsive (I) Inmate From: |
posted 04-15-2005 20:42
Hello everyone, I'm still learning javascript and want to try to keep everything compatible. I found something I want to play around and add to, you can look at the source here here if you want. Here is his body tag .. code: <body name="X" id="X" onLoad="DrawAll();" onkeypress="MainLoop();">
code: X.innerHTML = output;
|
Paranoid (IV) Inmate From: USA |
posted 04-15-2005 21:07
You're correct, innerHTML isn't standard: it's an MSIE extensions that's been adopted by all major browsers. code: <div id="foo">Hello, <b>I am</b> a <i>crazy</i> tag!</div>
code: document.getElementById("foo").innerHTML = "<a href='http://www.google.com/'>wee!</a>";
code: <div id="foo"><a href='http://www.google.com/'>wee!</a></div>
|
Nervous Wreck (II) Inmate From: |
posted 04-16-2005 18:56
Thanks for the reply, I thought that's what it did. Even though it has been adopted by most browsers, is there a better way to do it that is standard? I don't know if I'm making a big deal out of nothing, I just want to keep to the standards as much as possible. |
Paranoid (IV) Inmate From: USA |
posted 04-16-2005 21:26
The standard way to do it is using DOM methods; things like createElement, appendChild, setAttribute, etc. An example I've done can be found at http://www.rpi.edu/~laporj2/art/dynamic/javascript/pandachase/index.html , though the code is short, it's somewhat complex, so it may not be the best example. |