Log in

View Full Version : Href link attribute question



Cheng
04-16-2009, 08:24 AM
Hi.

Can someone please tell me what the correct link attribute is if I want the link opens a new window (no popup)?

I applied _blank which usualy works but if a popup blocker is enabled the new window won"t open and if the link is clicked together with the Ctrl key it opens a new tab instead of a new window.

What can be done in order to click the link together with the Ctrl key to open a new window or open a new window right away if no popup blocker is present?

Thanks in advance for any feedback,

Snookerman
04-16-2009, 09:30 AM
You can't and you shouldn't. Opening links in a new window or a new tab is a user setting and should be decided by the users themselves. If they want to open the link in a new window, they will right click the link and open it in a new window or just change their settings to always open in a new window. I would find it really annoying if links would open in new windows when I don't tell them to. Also, the target attribute is deprecated and should not be used at all.

Besides, tabbed browsing is there to avoid having multiple windows. If I control-click a link, I want it in a new tab and if a new window is opened, I would close down the site directly because it's not worth wasting my time on. (Sorry for the rant :D it's just that people don't seem to understand that users want to decide for themselves and just get annoyed if they can't.)

Cheng
04-16-2009, 12:12 PM
.......thanks for your reply and I kinda agree with you as well.

So you are suggesting to don't apply a link attribute at all, is that correct?

Sometimes a visitor don't want to be directed away from your page when he clicks on a link (i.e external) but that's the case if you don't apply any link attribute at all or am I mistaken?

I think if you don't apply the link attribute there won't be antoher tab opening up automatically instead you'll get to another website in the same tab window.

But if I'm wrong please correct me as I'm trying to learn.

Thanks again.......

Snookerman
04-16-2009, 12:30 PM
Glad to help! Yes, I am suggesting to not use a target attribute.

What you can (and should IMO) do is to help users that want to open external links in a new tab by telling them which links are external. They can then right click the link and chose a new tab or control click or scroll wheel click or whatever. You could put a small "external link image" after every external link, like Wikipedia does for instance (http://en.wikipedia.org/skins-1.5/monobook/external.png) or maybe use this nice script that pulls the favicon of the external page:
http://blog.liviuholhos.com/javascript/add-a-favicon-near-external-links-with-jquery (http://blog.liviuholhos.com/javascript/add-a-favicon-near-external-links-with-jquery)

The point is, it's the user's own decision how to open the link. The only thing you should do is to make it clear to them what type of link it is and the users will then decide how to open it.

molendijk
04-16-2009, 03:00 PM
Cheng, you mean something like this?:

<a href="http://www.google.com" onclick="window.open(this); return false">Open Google in new window</a>
===
Arie.

Cheng
04-17-2009, 10:57 AM
Cheng, you mean something like this?:

<a href="http://www.google.com" onclick="window.open(this); return false">Open Google in new window</a>
===
Arie.

.......thanks but I think that is no different from the _blank attribute or am I wrong.

At least it brings no differnet results in IE7.......

molendijk
04-17-2009, 01:31 PM
.......thanks but I think that is no different from the _blank attribute or am I wrong.
At least, you don't have to use the deprecated 'target=...'. And does the 'window.open' really get blocked?
===
Arie.

Cheng
04-17-2009, 04:53 PM
At least, you don't have to use the deprecated 'target=...'. And does the 'window.open' really get blocked?

.......yes, it does but I'm using your on click suggestion anyway instead of the target attribute by now.

Also I think the popup blocker I'm using is quiet aggressive as well but I'm used to it.

I'm using PopOops (http://www.gasanov.net/PopOops.asp) which is in my opinon everything you need (tiny but effective).

Thanks a lot for your feedback.......

vincentvu
05-16-2009, 11:14 PM
You know what, as I always think the target attribute would bring up the page just fine, and not being blocked by the popup blocker. Popup blockers only block those windows made by Javascript. I've never any problem with popup blockers when using the target=_blank though.