Created
June 10, 2009 15:21
-
-
Save oskarkrawczyk/127279 to your computer and use it in GitHub Desktop.
Returns all links that are not on the same domain as the website is.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Returns all links that are not on the same domain as the website is. | |
* | |
* $$('a:external') - Automatically checks for the domain name | |
* $$('a:external(example.com)') - Set a custom, base domain | |
* | |
* Example: | |
* | |
* $$('a:external').each(function(popup) { | |
* popup.addEvent('click', function(e) { | |
* e.stop(); | |
* window.open(this.get('href'), '_blank').focus(); | |
* }); | |
* }); | |
* | |
* Author: Oskar Krawczyk (oskar dot krawczyk dot com after nouincolor) | |
*/ | |
$extend(Selectors.Pseudo, { | |
external: function(domain) { | |
domain = $pick(domain, window.location.host.toString()); | |
return (!$(this).get('href').contains(domain) && !$(this).get('href').contains('#')); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment