Kit Grose wrote: > Just a note: > Your function doesn't currently use the RegExp function for anything > useful (you might as well use indexOf). RegExp is the right way to do > it, though, so you can enforce word boundaries to match complete > classNames only (if I want all a.pop to be new window links, I wouldn't > want a.popcorn to turn into a popup window). > > See http://snook.ca/archives/javascript/your_favourite_1/ for more info > (specifically the update) on how to enforce word boundaries but allow > for multiple classnames. >
good point - here it is modified to use word boundaries: function setNewWindowLinks(className) { var tags = document.getElementsByTagName('a'); var re = new RegExp('\\b' + className + '\\b'); if (tags.length > 0) { for (var i = 0; i < tags.length; i++) { if (tags[i].className.search(re) != -1) { tags[i].onclick = function() { window.open(this.href, '_blank'); return false; } } } } } ******************************************************************* List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] *******************************************************************