Target _blank

This is a discussion on "Target _blank" within the Web Page Design section. This forum, and the thread "Target _blank are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 3rd, 2007, 13:18
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Target _blank

Is there a way to make all links on your site open in a new page without manually entering target="_blank" to them all?

Jack
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote

  #2 (permalink)  
Old Oct 3rd, 2007, 13:22
welshstew's Avatar
Lead Administrator

SuperMember
Join Date: May 2007
Location: inside the outside
Posts: 1,388
Blog Entries: 13
Thanks: 1
Thanked 17 Times in 15 Posts
Re: Target _blank

ooohhh, why would you wnat to do this?
You should only be opening external links in a new window, internal links shold stay in the same one.
__________________
WelshStew
Lead Administrator

tierney rides tboard - uk site | xtreme wales - extreme clothing
If you think I've helped, click the "Thanks"
webforumz - facebook | LinkedIn
Last Blog Entry: Web Standards Curriculum Launched (Jul 8th, 2008)
Reply With Quote
  #3 (permalink)  
Old Oct 3rd, 2007, 13:24
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: Target _blank

It's for my ICT work. I have hundreds of links to pdf files with work in and they need to open in a new window if possible.
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
  #4 (permalink)  
Old Oct 3rd, 2007, 13:25
welshstew's Avatar
Lead Administrator

SuperMember
Join Date: May 2007
Location: inside the outside
Posts: 1,388
Blog Entries: 13
Thanks: 1
Thanked 17 Times in 15 Posts
Re: Target _blank

hhmmmm, place the following between your <head> tags and it should work:
Code: Select all
<base target="main">

Stew
__________________
WelshStew
Lead Administrator

tierney rides tboard - uk site | xtreme wales - extreme clothing
If you think I've helped, click the "Thanks"
webforumz - facebook | LinkedIn
Last Blog Entry: Web Standards Curriculum Launched (Jul 8th, 2008)
Reply With Quote
  #5 (permalink)  
Old Oct 3rd, 2007, 13:26
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: Target _blank

Yay it works! Thanks stew!
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
  #6 (permalink)  
Old Oct 3rd, 2007, 13:27
welshstew's Avatar
Lead Administrator

SuperMember
Join Date: May 2007
Location: inside the outside
Posts: 1,388
Blog Entries: 13
Thanks: 1
Thanked 17 Times in 15 Posts
Re: Target _blank

no probs
__________________
WelshStew
Lead Administrator

tierney rides tboard - uk site | xtreme wales - extreme clothing
If you think I've helped, click the "Thanks"
webforumz - facebook | LinkedIn
Last Blog Entry: Web Standards Curriculum Launched (Jul 8th, 2008)
Reply With Quote
  #7 (permalink)  
Old Oct 3rd, 2007, 15:25
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Target _blank

does that make it apply to everything though?
is there a way to do this on just some links?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #8 (permalink)  
Old Oct 3rd, 2007, 15:26
Marc's Avatar
Moderator

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Age: 15
Posts: 1,649
Thanks: 0
Thanked 8 Times in 8 Posts
Send a message via MSN to Marc Send a message via Skype™ to Marc
Re: Target _blank

Please remember for future purposes... the target="" attribute has been depreciated in strict doctypes.
Reply With Quote
  #9 (permalink)  
Old Oct 3rd, 2007, 16:15
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Target _blank

Quote:
Originally Posted by Marc View Post
Please remember for future purposes... the target="" attribute has been depreciated in strict doctypes.
Even in the base tag?
Didn't know that
thanks marc
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #10 (permalink)  
Old Oct 3rd, 2007, 16:17
Marc's Avatar
Moderator

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Age: 15
Posts: 1,649
Thanks: 0
Thanked 8 Times in 8 Posts
Send a message via MSN to Marc Send a message via Skype™ to Marc
Re: Target _blank

Quote:
Originally Posted by alexgeek View Post
Even in the base tag?
Didn't know that
thanks marc
I think so, it does have target="".
Reply With Quote
  #11 (permalink)  
Old Oct 5th, 2007, 14:43
moojoo's Avatar
Moderator
Join Date: Aug 2005
Location: Texas
Age: 31
Posts: 1,763
Blog Entries: 1
Thanks: 0
Thanked 18 Times in 18 Posts
Send a message via AIM to moojoo Send a message via MSN to moojoo Send a message via Yahoo to moojoo
Re: Target _blank

The best approach would probably use a small snippet of javascript and set rel="external" to the links you want opened in a new window. Its pretty snazzy from a validity and accessibility standpoint.

Code: Select all
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;
then on the links you would put:

Code: Select all
<a href="foo.html" title="Foo Fargh!" rel="external">Foo Foo</a>
__________________
The internet is just a fad.
http://www.mevans76.com
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
Reply With Quote
  #12 (permalink)  
Old Oct 12th, 2007, 09:34
New Member
Join Date: Jul 2006
Location: Derby
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Target _blank

I wanted to open all <a></a> tags within a specific <div> on one of my sites. It was a live Ebay listing and when people clicked 'buy it now' I wanted them to stay on my page but open the Ebay link in another window.

Anyway, I stumbled upon this nifty piece of code:

http://www.bennolan.com/behaviour/
Reply With Quote
  #13 (permalink)  
Old Oct 12th, 2007, 09:55
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Target _blank

Quote:
Originally Posted by moojoo View Post
The best approach would probably use a small snippet of javascript and set rel="external" to the links you want opened in a new window. Its pretty snazzy from a validity and accessibility standpoint.
No it's not.

You're using javascript to sneak around the validator. That's silly: you get the "valid HTML" badge, but your HTML is actually invalid, because it uses target="_blank" (after being rewritten by javascript). If you try validating your generated source code, then it will fail.

It also harms accessibility. Whatever fancy trick you use to implement target="_blank", it still takes control of the browser away from the user.

If you want to write invalid HTML, just do it -- don't use a fancy trick to pretend it's valid.

Last edited by MikeHopley; Oct 12th, 2007 at 09:59.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Target Window Name jayaramgussy Web Page Design 9 Sep 20th, 2007 22:44
The use of _blank... 1840dsgn Web Page Design 11 Jul 27th, 2007 23:40
Validating target Lchad Web Page Design 16 Jan 18th, 2007 13:36
XHTML Target JacobHaug Web Page Design 7 Jan 4th, 2007 11:55
Frameset target help please charter Flash & Multimedia Forum 4 Mar 28th, 2004 10:05


All times are GMT. The time now is 17:58.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43