Links directed to a new page or tab

This is a discussion on "Links directed to a new page or tab" within the Web Page Design section. This forum, and the thread "Links directed to a new page or tab are both part of the Design Your Website category.



 Subscribe in a reader

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

Notices


Reply
 
LinkBack Thread Tools
  #1  
Old Dec 25th, 2007, 00:04
Reputable Member
Join Date: Oct 2007
Location: At my house
Age: 22
Posts: 193
Thanks: 0
Thanked 0 Times in 0 Posts
Links directed to a new page or tab

How can I direct all of my links to a new page or window? www.adrian-rodriguez.net

I know the old way was

[code]
<a href="" target="_blank" />


But what is it now?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Dec 25th, 2007, 06:03
Ryan Fait's Avatar
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,787
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Links directed to a new page or tab

http://adactio.com/atmedia2005/

^ A very nice presentation on the subject.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Dec 25th, 2007, 21:20
Reputable Member
Join Date: Oct 2007
Location: At my house
Age: 22
Posts: 193
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Links directed to a new page or tab

I don't know much java, can it be done without it?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Dec 26th, 2007, 00:15
Highly Reputable Member
Join Date: Sep 2007
Age: 15
Posts: 717
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Links directed to a new page or tab

Well, first of all it's javascript. Java is something else entirely! Second, it becomes very difficult to do what you want without using one of those two methods (target="_blank" and the javascript way).
Last Blog Entry: Windows Vista vs. Mac Leopard (Nov 4th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Dec 26th, 2007, 19:55
Ed Ed is offline
Moderator
Join Date: Jul 2007
Location: Cork, Ireland
Posts: 726
Blog Entries: 1
Thanks: 0
Thanked 1 Time in 1 Post
Re: Links directed to a new page or tab

Just put this in the <head></head> of your page:

There's no need to know what it does - that is if it will confuse you.

Code: Select all
<script type="text/javascript">

function doPopups() {
  if (!document.getElementsByTagName) return false;
  var links = document.getElementsByTagName("a");
  for (var i=0; i < links.length; i++) {
    if (links[i].className.match("popup")) {
      links[i].onclick = function() {
        window.open(this.href);
        return false;
      }
    }
  }
}
window.onload = doPopups;

</script>
Then, instead of
HTML: Select all
<a href="yourlinkyhere">ToMySite</a> 
You just add a simple thing called a "class".

HTML: Select all
<a href="yourlinkyhere" class="popup">ToMySite</a>
Isn't is really simple?

Ed
Last Blog Entry: Happy New Year! (Dec 31st, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Dec 26th, 2007, 23:01
Highly Reputable Member
Join Date: Sep 2007
Age: 15
Posts: 717
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Links directed to a new page or tab

Actually, putting that into your <head> is not good. It creates certain issues with browsers. Take that code without the script tags, and put it into a separate document called script.js. Then, put the following into your head:
HTML: Select all
<script type="text/javascript" src="script.js"></script>
That way, your code is cleaner, and you avoid trouble with browsers misinterpreting the code.

Cheers
Last Blog Entry: Windows Vista vs. Mac Leopard (Nov 4th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Dec 27th, 2007, 13:56
Ed Ed is offline
Moderator
Join Date: Jul 2007
Location: Cork, Ireland
Posts: 726
Blog Entries: 1
Thanks: 0
Thanked 1 Time in 1 Post
Re: Links directed to a new page or tab

Oh...My Bad!

I just wanted to make it as easy as possible for him to use this method.
I actually hadn't realised it was bad to do it this way - I thought it was just better to do it externally!

Thanks,
Ed
Last Blog Entry: Happy New Year! (Dec 31st, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Dec 27th, 2007, 16:25
Highly Reputable Member
Join Date: Sep 2007
Age: 15
Posts: 717
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Links directed to a new page or tab

No problem. It's just that learning something the correct way is better than learning the incorrect way, and figuring out it's bad a long time later.
Last Blog Entry: Windows Vista vs. Mac Leopard (Nov 4th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Dec 29th, 2007, 22:28
Most Reputable Member
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Links directed to a new page or tab

Don't use javascript to sneak around deprecated code. That's just silly.

If you insist on opening windows, use target="blank". It's the simplest method.

So what if it's invalid? All of the "clever" workarounds do nothing but hide the error from the validator. This code was deprecated for a reason.

But really, why should you ever use this? Don't wrest control from the user.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Dec 30th, 2007, 11:46
Ed Ed is offline
Moderator
Join Date: Jul 2007
Location: Cork, Ireland
Posts: 726
Blog Entries: 1
Thanks: 0
Thanked 1 Time in 1 Post
Re: Links directed to a new page or tab

You see - I have no clue whatsoever.

All I did was go to the link and bring the code here - I assumed that it was the W3C way to do it!

Thanks for pointing things like this out - as it is anyway, I wouldn't be forcing pop-ups on anyone or having it in a link, I much prefer to right-click and choose to open it up in a new tab or window, but when I don't want it to move and it does, I have to say it really annoys me.

Thanks,
Ed
Last Blog Entry: Happy New Year! (Dec 31st, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old Dec 30th, 2007, 12:19
Most Reputable Member
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Links directed to a new page or tab

By the way, there's nothing wrong with the concept of a "pop-up" box. It is often user-friendly.

The problem is with its implementation as a new browser window.

Using CSS instead, you can get all of the advantages and none of the drawbacks. Simply use absolute positioning. For example, see the behaviour of my "pop-up" boxes on http://www.badmintonbible.com: look at the preferences menu on the right; the red links "what does this do?" and "how can I use these?" create pop-up <div>s.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old Jan 1st, 2008, 12:55
Reputable Member
Join Date: Oct 2007
Location: At my house
Age: 22
Posts: 193
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Links directed to a new page or tab

Thanks for the tip Mike. I guess if people really wanted to go back to my site then it would be worth them having to type it in all over again. Happy New Year!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13  
Old Jan 1st, 2008, 13:09
Most Reputable Member
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Links directed to a new page or tab

Quote:
Originally Posted by thewebkid View Post
Thanks for the tip Mike. I guess if people really wanted to go back to my site then it would be worth them having to type it in all over again. Happy New Year!!
The idea that "opening new windows stops people from leaving my site" is a misconception.

You can't stop users leaving your site, but you can annoy them by trying. Ironically, opening a new window/tab makes it harder for users to return to your site, because the back button -- the most fundamental user navigation mechanism -- will not work.

And happy new year to you, sir!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
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
links page littlebilly Starting Out 7 Jul 25th, 2007 20:22
How is a links page structured? dlking1000 Link Building and Link Sales 1 Apr 27th, 2007 23:42
Anchors. and links within the same page Accurax Web Page Design 3 Feb 23rd, 2007 19:50
links to different points on the same page bruno89 Web Page Design 13 Nov 9th, 2006 00:14
Numbered links to every page dinahdoey Classic ASP 5 Sep 12th, 2004 17:01


All times are GMT. The time now is 08:30.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization 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