innerHTML / IE6 /NN7

P

Phil N

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;
}

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

--
Phil Newcombe - philn?telus?net
http://www3.telus.net/bikim

Netscape/Gecko/Mozilla - standards conformance and cooperation
Internet Explorer - standards obfuscation and divergence
Linux += 30,000/Germany + 80,000/Spain + tomorrow
 
Y

yzzzzz

Scripsit "Phil N":
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;
}

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


You should use an IFrame, it'll be much more accessible and easy to
maintain than Javascript code (and some people disable javascript to
avoid popups...).

But the javascript works fine for me, no errors (IE6 and Mozilla 1.4).
 
P

Phil N

yzzzzz said:
You should use an IFrame, it'll be much more accessible and easy to
maintain than Javascript code (and some people disable javascript to
avoid popups...).

But the javascript works fine for me, no errors (IE6 and Mozilla 1.4).

Thanks - I'll look at IFrames. Maybe because I don't have the service packs
installed? My box went berserk last time I tried that and I had to do a
pcrestore thing from the W98 cd to get it back.

--
Phil Newcombe - philn?telus?net
http://www3.telus.net/bikim

Netscape/Gecko/Mozilla - standards conformance and cooperation
Internet Explorer - standards obfuscation and divergence
Linux += 30,000/Germany + 80,000/Spain + tomorrow
 
D

DU

Phil said:
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/doctorunclear/HTMLJavascriptCSS/innerHTMLvsNodeValue.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/doctorunclear/HTMLJavascriptCSS/DOM1CharacterData.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
 
D

DU

DU said:
Phil said:
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/doctorunclear/HTMLJavascriptCSS/innerHTMLvsNodeValue.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/doctorunclear/HTMLJavascriptCSS/DOM1CharacterData.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

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
 
P

Phil N

DU said:

-- Not sure if this will appear in the right order in the thread as my ISP seems
to be delaying some of my posts/emails lately. So this should be after my last
one. --

Sorry, forgot to mention I'm not using toggleText() _or_ displayText() here.

I've changed tA.innerHTML = text;

to
tA.childNodes[0].nodeValue = text;

as you suggested but it doesn't do what I want - it just displays the raw ascii
text. I'm sure you understand that but I want to display the actual rendered
page.

(I wonder if learning JS/DOM/CSS+browser inconsistencies/bugs+xml/xhtml/ad
nauseum. is more confusing than calculus?)


--
Phil Newcombe - philn?telus?net
http://www3.telus.net/bikim

Netscape/Gecko/Mozilla - standards conformance and cooperation
Internet Explorer - standards obfuscation and divergence
Linux += 30,000/Germany + 80,000/Spain + tomorrow
 

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top