/    Sign up×
Community /Pin to ProfileBookmark

Does Internet Explorer 8 still ignore new lines and NOT treat them like text nodes?

Since I only have a Mac computer available to me, I can’t verify this myself. But can someone tell me if Internet Explorer 8, which I believe is the current version of IE (and has about 25% market share), still ignores new lines and does NOT treat them as text nodes like in previous versions of IE, or has it finally caught up with other browsers like Firefox and Chrome and treat new lines as text nodes?

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@tirnaApr 06.2010 — ........ But can someone tell me if Internet Explorer 8, which I believe is the current version of IE (and has about 25% market share),.........[/quote]

Browser popularity statistics from the w3schools website. I don't know how accurate they are.

[URL]http://www.w3schools.com/browsers/browsers_stats.asp[/URL]
Copy linkTweet thisAlerts:
@KorApr 06.2010 — But can someone tell me if Internet Explorer 8, which I believe is the current version of IE (and has about 25% market share), still ignores new lines and does NOT treat them as text nodes like in previous versions of IE[/QUOTE]
IE 8 counts the DOM textnodes exactly like the previous versions (6 and 7). That means it will not count all the possible textnodes.
Copy linkTweet thisAlerts:
@aj_nscApr 06.2010 — Browser popularity statistics from the w3schools website. I don't know how accurate they are.

[URL]http://www.w3schools.com/browsers/browsers_stats.asp[/URL][/QUOTE]


For the record, stats are probably better from W3Counter:

http://www.w3counter.com/globalstats.php

Probably where the OP got his stats from (IE8 is 24.67%)
Copy linkTweet thisAlerts:
@Gary_KingauthorApr 06.2010 — IE 8 counts the DOM textnodes exactly like the previous versions (6 and 7). That means it will not count all the possible textnodes.[/QUOTE]
Okay, so I guess the best way to ensure that a script works in both Firefox and IE when I'm looping through nodes is to check if the current node is a text node, and if it is, ensure that it is not empty?
Copy linkTweet thisAlerts:
@mrhooApr 06.2010 — The best way is to test your pages in various versions of IE, and in older versions of safai,opera and firefox, as well as the newest.

Or restrict your scripts to only run in your tested environment.

Every browser has its own peculiarities-
Copy linkTweet thisAlerts:
@rnd_meApr 06.2010 — Okay, so I guess the best way to ensure that a script works in both Firefox and IE when I'm looping through nodes is to check if the current node is a text node, and if it is, ensure that it is not empty?[/QUOTE]

grab the innerText of elements, and forget about messing with text nodes.

here's a helper that extracts text from child-less elements only:
[CODE]
function text(node){
if(node.getElemementsByTagName &&
!node.getElemementsByTagName("*").length){
return node.innerText||node.textContent||node.innerHTML;
}else{
return "";
}
}[/CODE]


you can put the text in a hidden textarea, process it with JS, and display the results in a visible div next to the hidden textarea.

that would preserve line breaks, even in IE.
×

Success!

Help @Gary_King spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.11,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...