Overclock.net banner
1 - 12 of 12 Posts

·
Registered
Joined
·
1,494 Posts
Quote:
New Windows with HTML

Forcing a link to open in a new window is simply a matter of adding an additional attribute to the link's code. Suppose you have a straightforward link to a page. The visitor sees something like...

Visit Fontstuff today!

Here's the code...

Visit http://www.fontstuff.com">Fontstuff</a> today!

Now let's modify the link to force it to open the linked page in a new window. What the visitor sees is no different...

Visit Fontstuff today!

...but when they click the link a new browser window opens displaying the linked page inside. Here's the code...

Visit http://www.fontstuff.com" target="_blank">Fontstuff</a> today!

The addition of the TARGET attribute to a hyperlink lets you dictate where the linked page opens. To open a new page I have used target="_blank" but there are others...
target="_blank" Opens the linked page in a new window.
target="_self" Opens the linked page in the same window. This is the default for ordinary pages and doesn't need to be specified. It has a use when working with frames.
target="_parent" Opens the linked page in the parent frame in a frames page.
target="_top" Opens the linked page in a full (i.e. top level) window when used in frames pages. This one is useful for letting a linked page 'break out' of a frame.

In fact, you can insert any window name that you might have defined elsewhere. Using the JavaScript technique outlined below you could create a new window with a particular name, then use this method to cause all subsequent linked pages to open in it. (Find out how to do this and check out the demo!)
Setting a Default

If you want all the links on your page to open in a new window you don't have to modify every one. It's a simple matter to apply a default setting for the page so that all the links behave the same way. Here's how...

Insert the following code...

...into the header of your document's HTML (i.e. anywhere between the and tags but not inside any other pairs of tags already there). You can substitute "_blank" with one of the other names if appropriate.

Got it from here

Will do a new window in IE, new tab in FF.
 

·
Registered
Joined
·
2 Posts
This is what I have used to open a link to a new window but what about a TAB?
I did a google search for TAB and got this thread which utilizes the target attribute.

Is there a way to make it open a new tab? Code would be greatly appreciated.

Sorry for the necro post.
 

·
Pink Freud
Joined
·
2,699 Posts
_blank Opens the linked document in a new window or tab depending on the browser or the browser's preferences for the user.

If you want to force, you would need to use javascript.
However, the target attribute is supported by every browser, whereas javascript can be disabled and many people have it disabled (or blocked by many reasons)
 

·
Registered
Joined
·
2 Posts
Thanks for the quick assist guys. So it seems not until a universal browser support of C5 code will there be a _tab assignment for the target variable.
Yes it is only browser specific how a new window is handled. I too use the middle button "trick" but visitors to my client's site may not know this and I was looking for a way to force tabbed browsing on tab capable browsers. For now, new window it is for IE folks.
 

·
Pink Freud
Joined
·
2,699 Posts
Quote:
Originally Posted by overclockdotnet View Post

Thanks for the quick assist guys. So it seems not until a universal browser support of C5 code will there be a _tab assignment for the target variable.
Yes it is only browser specific how a new window is handled. I too use the middle button "trick" but visitors to my client's site may not know this and I was looking for a way to force tabbed browsing on tab capable browsers. For now, new window it is for IE folks.
Like I said, if you really want to force new tabs to open, you could use javascript.
The safer solution would be to use javascript to open a new tab if possible, if not, opening a new window/tab with html
 
1 - 12 of 12 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top