Results 1 to 9 of 9

Thread: Href link attribute question

  1. #1
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Question Href link attribute question

    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,
    Cheng

  2. #2
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    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 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.)

  3. #3
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    .......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.......
    Cheng

  4. #4
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    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 () 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

    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.

  5. #5
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    Cheng, you mean something like this?:
    Code:
    <a href="http://www.google.com" onclick="window.open(this); return false">Open Google in new window</a>
    ===
    Arie.

  6. #6
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by molendijk View Post
    Cheng, you mean something like this?:
    Code:
    <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.......
    Cheng

  7. #7
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    Quote Originally Posted by Cheng View Post
    .......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.

  8. #8
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    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 which is in my opinon everything you need (tiny but effective).

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

  9. #9
    Join Date
    May 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •