If you want the code, for your site, you can get it here.
Link Target Preferences
The Link Target Preferences system has the following main purposes:
- By default, all external links open in the same window
- The checkbox visually indicates to the end user, the state which link targets have
- The end user can click this checkbox to change that preference
- Any changed preferences is stored in a cookie for future use
The system is designed to be simple plug and play. For PHP aficionados, all code can be moved into an external include—even the “onload” code, which doesn’t use the default
body onload="" method. The system will work out of the box, however, so it is easier for you to just grab the sample HTML file than show the code for it here.
I have commented out sections of the sample page, with advice on how each snippet should be used:
each snippet being followed by the code in question.
The changes that have to be made, reside in the top of the HTML page:
var url_1 = "http://www.example.com"; var url_2 = "http://example.com";
As you can see, change
http://example.com to your own web server. This makes sure that on-site links doesn’t suddenly open in a new browser window.
var open_blank_default = false;
specifies the user experience for first time visitors. A
true opens external links in a new window.
var site_title = "example";
makes sure there are no cookie conflicts. Not entirely sure if this is necessary, but better make sure.
- 1.0: Initial release
- 1.1: Based on feedback, I moved all configuration into simple variables in the beginning of the file. There’s no longer any need to dig into the code. Also added CSS for a “hand” cursor and hover color for the
The code validates, and works quite simply. I find it is most useful for Internet Explorer users, but you may use it if you find the need for it. Any questions are welcome.