Left Quote    Maybe this world is another planet's Hell.
- Aldous Huxley    
Right Quote
[login] | [Register]

New windows without using the target attribute

by: sm0ke
Page: 1 of 2
(View All)

[b]Introduction[/b] Should we open links in a new window? or should we give the user a choice? This is in fairness quite a hotly debated argument in certain circles, to force a users hand or to let them choose. A lot of people against the idea of opening links in a new window say that the user can right click the link and choose to open a new window or not. Personally I dont see more than 4% of my users knowing they can do this (based on experience). As you may or may not know, when writing web documents in XHTML using a Strict doctype, the commonly used [b]target="_blank"[/b] attribute of the anchor tag (used to force links to open in a new window) is no longer valid. So we need a new way to accomplish it. I'm going to show you two ways of opening the links in a new window, both require the user to have javascript enabled but the second methos will still create a functioning link which opens ion the same window if javascript is disabled. [b]JavaScript popup[/b] Paste the following code between the tags of your page: [code] [/code] Next we need to create the link. Paste the following between the tags of your page: [code] This is the link text [/code] Ok, thats the first method done with, its quick, easy and painless.

Javascript rel=external

The following function was written by Roger Johansson,
Save this file as jstarget.js

You can remove the "Warning opens in a new window" by editing line 6 and the final line. To call the script into the html document you want to create the links in put the following between the tags: [code] [/code] And finally the link is set as: [code] Link to Some Site [/code] So, weather you like opening links in new windows or not, at times its unavoidable and you now have 2 new ways to accomplish it if using the XHTML Strict doctype, or even if you just want to stop using target tags. The seccond method is more expandable than the first, you can add to it and make the script your own, but please post any major additions or improvements to the original author linked above.

1  |  2  |  
Next »

No Comments for this page.

You Must be logged in or a member to comment.

Tutorial Stats

Tutorial Stats

0 Total Comments
0 Rating of 5 ( Votes)


Tutorial Options

· Login to Rate This Article
· Login to Post a Comment
· Read more by this author
Digg This Article! Bookmark This Article Reddit: Bookmark This Article BlinkList: Blink This Article! YahooMyWeb BlogMarks: Add This Mark! Furl: Save This Article Spurl: Mark This Article



· Site Design Made Simple
· HTML Tutorial
Your Article Here

"" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank