Open external links in a new window - Version 1.1.0

Version Description

Changed: Better practice for opening links. The plugin now uses the onClick-attribute instead of writing JavaScript directly into the href-attribute. This enables users to right-click the link and open in a new window/tab, save the target etc.

Download this release

Release Info

Developer kezze
Plugin Icon 128x128 Open external links in a new window
Version 1.1.0
Comparing to
See all releases

Code changes from version 1.0 to 1.1.0

open-external-links-in-a-new-window.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Open external links in a new window
4
  Plugin URI: http://wordpress.org/extend/plugins/open-external-links-in-a-new-window/
5
  Description: Opens all external links in a new window. XHTML Strict compliant and search engine optimized (SEO).
6
  Author: Kristian Risager Larsen
7
- Version: 1.0
8
  Author URI: http://kezze.dk
9
  */
10
 
@@ -25,10 +25,9 @@ function external_links_in_new_windows()
25
  for (var t=0; t<document.links.length; t++) {
26
  var all_links = document.links[t];
27
  if (all_links.href.search(/^http/) != -1) { // Catches both http and https
28
- if (all_links.href.search('/".$blogdomain['host']."/') == -1) {
29
- // all_links.setAttribute('target', '_blank');
30
- document.links[t].setAttribute('href', 'javascript:window.open(\\''+all_links.href+'\\'); void(0);');
31
- document.links[t].setAttribute('target', '');
32
  }
33
  }
34
  }
4
  Plugin URI: http://wordpress.org/extend/plugins/open-external-links-in-a-new-window/
5
  Description: Opens all external links in a new window. XHTML Strict compliant and search engine optimized (SEO).
6
  Author: Kristian Risager Larsen
7
+ Version: 1.1.0
8
  Author URI: http://kezze.dk
9
  */
10
 
25
  for (var t=0; t<document.links.length; t++) {
26
  var all_links = document.links[t];
27
  if (all_links.href.search(/^http/) != -1) { // Catches both http and https
28
+ if (all_links.href.search('/".$blogdomain['host']."/') == -1 && document.links[t].hasAttribute('onClick') == false) {
29
+ document.links[t].setAttribute('onClick', 'javascript:window.open(\\''+all_links.href+'\\'); return false;');
30
+ document.links[t].removeAttribute('target');
 
31
  }
32
  }
33
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/xclick/business=paypal%40kezze.dk&item_name=
4
  Tags: links, external links, target blank, target new, window.open, new window, blank window, new tab, blank tab, tabs, SEO, xhtml strict, javascript
5
  Requires at least: 2.0
6
  Tested up to: 3.0
7
- Stable tag: 1.0
8
 
9
  Opens all external links in a new window. XHTML Strict compliant and search engine optimized (SEO).
10
 
@@ -12,7 +12,7 @@ Opens all external links in a new window. XHTML Strict compliant and search engi
12
  Opens all external links (starting with `http://` or `https://`) in a separate browser window.
13
  The plugin produces XHTML Strict compliant code and is also search engine optimized (SEO).
14
 
15
- This is done using the `javascript:window.open()`-function.
16
 
17
  Most other plugins perform a hack by altering the `target` parameter (i.e. `<a href="http://somewhere.example" target="_blank">`). That method is not XHTML Strict compliant.
18
  This plugin handles the links client-side, which lets search engines follow the links properly. Also, if a browser does not support JavaScript, the plugin is simply inactive, and does not result in any errors.
@@ -25,6 +25,12 @@ Based on the source of [Zap_NewWindow](http://www.zappelfillip.de/2005-12-05/zap
25
 
26
  == Changelog ==
27
 
 
 
 
 
 
 
28
  = 1.0 =
29
  Fixed: Credits to Tom K&ouml;hler (Charset)
30
  Fixed: Links
@@ -34,6 +40,12 @@ Initial release
34
 
35
  == Upgrade Notice ==
36
 
 
 
 
 
 
 
37
  = 1.0 =
38
  Ready for production.
39
 
4
  Tags: links, external links, target blank, target new, window.open, new window, blank window, new tab, blank tab, tabs, SEO, xhtml strict, javascript
5
  Requires at least: 2.0
6
  Tested up to: 3.0
7
+ Stable tag: 1.1.0
8
 
9
  Opens all external links in a new window. XHTML Strict compliant and search engine optimized (SEO).
10
 
12
  Opens all external links (starting with `http://` or `https://`) in a separate browser window.
13
  The plugin produces XHTML Strict compliant code and is also search engine optimized (SEO).
14
 
15
+ This is done using JavaScript's `window.open()`-function.
16
 
17
  Most other plugins perform a hack by altering the `target` parameter (i.e. `<a href="http://somewhere.example" target="_blank">`). That method is not XHTML Strict compliant.
18
  This plugin handles the links client-side, which lets search engines follow the links properly. Also, if a browser does not support JavaScript, the plugin is simply inactive, and does not result in any errors.
25
 
26
  == Changelog ==
27
 
28
+ = 1.1.0 =
29
+ Changed: Better practice for opening links. The plugin now uses the onClick-attribute instead of writing JavaScript directly into the href-attribute. This enables users to right-click the link and open in a new window/tab, save the target etc.
30
+
31
+ = 1.0.1 =
32
+ Fixed: Removes target attribute from links instead of setting the attribute to null. (Thanks to [crashnet](http://wordpress.org/support/topic/plugin-open-external-links-in-a-new-window-target-attribute-left-empty?replies=2))
33
+
34
  = 1.0 =
35
  Fixed: Credits to Tom K&ouml;hler (Charset)
36
  Fixed: Links
40
 
41
  == Upgrade Notice ==
42
 
43
+ = 1.1.0 =
44
+ Better practice for opening links. Please upgrade.
45
+
46
+ = 1.0.1 =
47
+ Minor bugfix.
48
+
49
  = 1.0 =
50
  Ready for production.
51