Hi guys, I'm learning the prototype library after coming from jQuery, and I'm trying to write a simple snippet that opens external links in a new window.
This doesn't seem to work in Firefox, or Safari, and I'm not sure what I'm doing wrong here, I'm sure it's something really obvious, but I've been staring at this code for so long now that I've effecitvely gone snow blind. Can anyone help? I'm using prototype 1.6.0.1, and I'm on a mac. // goal - select all external links and onclick, open that link in a new window, in an unobtrusive manner var openNewWindow = function(element) { element.observe('click', function() {window.open(element.href);} ); }; // begin constructing regexp that makes any url with the host domain in it, and with the optional www prefix var internalUrl = "/" + "(www)?" + document.location.hostname + "/"; // turn string into regexp to match against var pattern = eval(internalUrl); // reject all links whose href matches the host domain regexp defined above filteredResult = result.reject(function(e) { return e.href.match(pattern); }); add onclick handler each member of the array of remaining links filteredResult.invoke('openNewWindow'); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---