Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > innerHTML / IE6 /NN7

Reply
Thread Tools

innerHTML / IE6 /NN7

 
 
Phil N
Guest
Posts: n/a
 
      07-13-2003
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

 
Reply With Quote
 
 
 
 
yzzzzz
Guest
Posts: n/a
 
      07-13-2003
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).

 
Reply With Quote
 
 
 
 
Phil N
Guest
Posts: n/a
 
      07-13-2003
yzzzzz wrote:

> 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

 
Reply With Quote
 
DU
Guest
Posts: n/a
 
      07-14-2003
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/

 
Reply With Quote
 
DU
Guest
Posts: n/a
 
      07-14-2003
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/

 
Reply With Quote
 
Phil N
Guest
Posts: n/a
 
      07-14-2003
DU wrote:

> DU
> --
> Javascript and Browser bugs:
> http://www10.brinkster.com/doctorunclear/
>


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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
innerHTML problem in IE6 Kiran Makam HTML 11 08-28-2008 01:59 PM
Ampersand creating problem in IE6 innerHTML property Kiran Makam Javascript 4 08-26-2008 02:59 PM
xhtml, innerHtml, appendChild, and innerHTML. what is the exact proper way to do this with DOM sonic Javascript 5 07-11-2006 08:17 AM
IE6 SP1 rendering vs IE6 SP2 rendering Peter Mount HTML 4 01-31-2006 08:01 AM
Just one ie6 template that works with ie6!? Ivor O'Connor HTML 4 11-25-2003 09:16 PM



Advertisments