Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-10-2004, 10:03 PM   PM User | #1
Choopernickel
Regular Coder

 
Join Date: Apr 2003
Location: Atlanta, GA
Posts: 487
Thanks: 0
Thanked 0 Times in 0 Posts
Choopernickel is an unknown quantity at this point
Node emptier

From a different challenge involving time-sensitive text, I came up with this little goodie.

Code:
function clearNode (node) {
    node.normalize();
    while (node.childNodes.length > 0) {
        node.removeChild(node.firstChild);
    }
    return node;
}
I'd like to make this a method of the Node prototype, but I haven't figured out *quite* how to do it yet. Comments? Improvements?
Choopernickel is offline   Reply With Quote
Old 02-10-2004, 10:49 PM   PM User | #2
liorean
The thread killer


 
Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
liorean will become famous soon enoughliorean will become famous soon enough
Didn't normalise have the irritating property that it crashes some version of ie? I think I remember something like htat happening. Anyway, the Node object is only exhibited by Opera and Mozilla for the moment, so you'de not going to find a way to do that. Make it a global function instead.
__________________
liorean <[lio@wg]>
Articles: RegEx evolt wsabstract , Named Arguments
Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards
liorean is offline   Reply With Quote
Old 02-21-2004, 03:34 AM   PM User | #3
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
Are you looking to remove useless whitespace text nodes from a node tree? Cos Alex Vincent wrote a nifty method for that - http://www.codingforums.com/showthre...&threadid=7028

Except don't let it run in mac/ie5, because in that browser HTML structures become unstable when stripped of whitespace.
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark
brothercake is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 07:54 PM.


Advertisement
Log in to turn off these ads.