...

View Full Version : External Link



nathan130
10-24-2008, 02:38 AM
How do i make it so the link opens in a new page?

rangana
10-24-2008, 04:32 AM
<a href="http://www.google.com" target="_blank">Open Google in new window</a>


For further reading:
http://www.w3schools.com/TAGS/tag_a.asp
http://www.htmlcodetutorial.com/linking/_A_TARGET.html
http://www.trilithium.com/johan/2005/03/target-blank/

...but you should also note that having target attribute will fail validation on strict doctype.

Bill Posters
10-24-2008, 09:58 AM
Fwiw

Flag & toggle external links (http://dev.akabillposters.com/dom-js/flag-toggle-external-links/)

Pennimus
10-27-2008, 02:45 PM
Really interesting idea there Bill - but the links don't work for me once I've toggled them to open in a new window. Looking at it, I can't see how you are getting them to open in a new window - JavaScript? Perhaps that's the root of the problem?

gnomeontherun
10-27-2008, 03:55 PM
I think the important part of that post is to show it is a good idea to have a little 'new window' icon near external links. This way they know they are external. Then they can choose to open them in a new window or tab themselves. That way the browsing experience is more in control of the visitor, which gives them a nice warm feeling inside.

Bill Posters
10-27-2008, 05:07 PM
Really interesting idea there Bill - but the links don't work for me once I've toggled them to open in a new window. Looking at it, I can't see how you are getting them to open in a new window - JavaScript? Perhaps that's the root of the problem?

Now fixed.
I must have absent-mindedly fiddled with the code and left it unfinished/broken.

I've also ditched the non-jQuery options (simpler for maintenance, as I use jQuery as my primary framework).

HTH :)



…all fwiw, of course.

oesxyl
10-27-2008, 06:06 PM
How do i make it so the link opens in a new page?
for html can use target as rangana said or in xhtml can use javascript:



<a href="your url here" onclick="window.open('your url here'); return false;">....</a>

url in both places, must be in href for the case when javascript is disabled.

best regards

Bill Posters
10-27-2008, 06:12 PM
for html can use target as rangana said or in xhtml can use javascript:
Fwiw, it's not an HTML compared to XHTML issue. It's a Transitional compared to Strict issue. The target attribute is not valid in either HTML 4.01 Strict or XHTML 1.0 Strict.



<a href="your url here" onclick="window.open('your url here'); return false;">....</a>


To save a little time, you don't need to repeat the href value in the window.open() method. Simply refer back to the href value in the js.

e.g.

<a href="your url here" onclick="window.open(this.href); return false;">....</a>

Apostropartheid
10-27-2008, 06:52 PM
I feel obligated to point out that opening links in new windows is both annoying in the tabbed age and isn't good for accessibility (http://diveintoaccessibility.org/day_16_not_opening_new_windows.html).

gnomeontherun
10-27-2008, 07:12 PM
I feel obligated to point out that opening links in new windows is both annoying in the tabbed age and isn't good for accessibility (http://diveintoaccessibility.org/day_16_not_opening_new_windows.html).

Thank you! Exactly what I was trying to say! :thumbsup:

oracleguy
10-27-2008, 07:41 PM
I feel obligated to point out that opening links in new windows is both annoying in the tabbed age and isn't good for accessibility (http://diveintoaccessibility.org/day_16_not_opening_new_windows.html).

I agree, you should only open new windows when absolutely necessary.

oesxyl
10-28-2008, 10:15 AM
How do i make it so the link opens in a new page?


I feel obligated to point out that opening links in new windows is both annoying in the tabbed age and isn't good for accessibility (http://diveintoaccessibility.org/day_16_not_opening_new_windows.html).


Thank you! Exactly what I was trying to say! :thumbsup:


I agree, you should only open new windows when absolutely necessary.
I'm not agree, if you don't abuse it is ok. Anyway this was op request.

best regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum