DU wrote:
Phil N wrote:
Hello again
Site I'm working on: http://www3.telus.net/bikim/lightning/test/
- 'coach' & 'main' links swap innerHTML of div element - id 'textArea'
works fine in NN7; IE6 reports 'Object doesn't support this property
or method'
code is:
function showText(text)
{
var tA = document.getElementById('textArea');
tA.innerHTML = text;
tA.childNodes[0].nodeValue = text;
or
tA.childNodes[0].data = text;
or
tA.firstChild.nodeValue = text;
or
tA.firstChild.data = text;
will all work faster (from 300% to 2000%) than resorting to non W3C web
standard innerHTML.
}
If the text parameter is a string, then there is no need to resort to
innerHTML. Just use valid W3C DOM 1 characterData data property or
nodeValue for such text node.
Performance comparison between innerHTML method and DOM's nodeValue when
changing, modifying the text data of a node of type TEXT_NODE
http://www10.brinkster.com/doctorunc...NodeValue.html
W3C DOM 1 CharacterData methods and properties are perfectly supported
by recent versions of major browser manufacturers and other W3C DOM 1
compliant browsers.
DOM level 1 CharacterData Interface attributes and methods tests
http://www10.brinkster.com/doctorunc...acterData.html
Microsoft website says getElementById and innerHTML are supported.
Maybe my function call:
<a href="javascript:showText(coachText)">coach</a>
<a href="javascript:showText(mainText)">main</a>
Thanks
It is widely known and almost universally recognized that resorting to
"javascript:" pseudo-protocol in href attribute is wrong, bad and bound
to create problems unless you're creating a bookmarklet.
http://jibbering.com/faq/#FAQ4_24
Top Ten Web-Design Mistakes of 2002
6. JavaScript in Links
"A link should be a simple hypertext reference that replaces the current
page with new content. (...) of course (...) link is not a piece of code
that interferes with the browser’s standard behavior."
http://www.useit.com/alertbox/20021223.html
"Don't use javascript: URLs
Using a straight http: URL will allow any browser to access the link. If
you want to use JavaScript for browsers that have JavaScript enabled,
use the onMouseOver and onClick attributes of the <a href> tag."
http://www.rahul.net/aahz/javascript.html#remove
DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
Please ignore the innerHTML vs nodeValue reference here. Your parameter
identifiers (function names, parameters, id values) are extremely
confusing. You're not passing a real TEXT_NODE to your displayText and
showText functions but markup value first converted as string to be
processed as new html nodes.
I would do things quite differently if I were you. Just a <div></div>
with display:none and with the ability to modify its text node only.
Maybe there would be more faster, efficient way to do all this... if we
knew your webpage situation, context more.
DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/