Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leejones/prepare_links
jQuery plugin to launch external links in a new window automatically.
https://github.com/leejones/prepare_links
Last synced: about 1 month ago
JSON representation
jQuery plugin to launch external links in a new window automatically.
- Host: GitHub
- URL: https://github.com/leejones/prepare_links
- Owner: leejones
- License: mit
- Created: 2009-08-17T21:11:13.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2010-01-31T15:43:05.000Z (almost 15 years ago)
- Last Synced: 2023-04-18T19:50:39.365Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 125 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.mdown
- License: LICENSE
Awesome Lists containing this project
README
# jQuery Prepare Links Plugin
Automagically open links to other sites in a new window.
I'm generally not a huge fan of opening links in a new window, but clients frequently want this functionality on their sites.
## Basic Usage
Opens all links outside of your domain in a new window.$(document).ready(function() {
$("a").prepare_links();
});
Considers same domain, subdomain, and localhost to be internal links by default. See the options to change default behavior.## Options
subdomains_are_external
boolean
defaults to false
determines whether subdomains like www.example.com and blog.example.com open in a new windowadditional_internal_sites
array
defaults to empty
allows you to specify additional domains that should open in the same window### Example with options
$(document).ready(function() {
// build options for prepare links
var options = {
subdomains_are_external : true,
additional_internal_sites : [
"http://github.com",
"http://google.com"
]
};// call prepare links with predefined options
$("a").prepare_links(options);
});Links for the current domain, github.com, and google.com will open in the current window. All other links including subdomains will open in a new window.
## Feedback
If you find a bug, please write a unit test for it and submit a patch. You can also raise an issue on [github](http://github.com/leejones/prepare_links).