Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Internal vs External Links

edited July 2006 in Vanilla 1.0 Help
Is there any way to get internal forum links to always open in the same window, yet have all external links open in a new window, by default?

I guess there must be a better way to do it than using 'base', '_top' and '_blank' html definitions...
«1

Comments

  • Options
    Actually, using the target attribute to open links in a new window is not standard-approved.
  • Options
    i've read that before, bergamot... but what is the correct method?
  • Options
    edited April 2006
    The popular methods include

    1. Saying "fuck it" and using the target attribute anyway
    2. Opening a new window with javascript (a little buggy)
    3. Letting users choose whether they want to open a link in a new window or not through the standard browser mechanism.
  • Options
    MarkMark Vanilla Staff
    I'm a fan of #3 personally.
  • Options
    Ditto on 3. I wish I could right-click and get an 'open in same window' option for some of the more obnoxious sites I visit.
  • Options
    MarkMark Vanilla Staff
    edited April 2006
    Firefox+CTRL+Click is the shiz.
  • Options
    I would like an addon for firefox (or javascript) where the browser uses the same window for sites with the same base name. For links to other sites it should pop out a box on left click to ask you if you want it in the same window or in a new tab/window.

    Is there any firefox addon which lets you chose to open a link in the current tab (even if its targeted blank)?
  • Options
  • Options
    That one was lovely!
  • Options
    Firefox+CTRL+Click is the shiz.
    They borrowed it from safari, but neglected to borrow a few minor corollary features (like Ctrl-Enter in the address bar or google bar would open the results in a new tab)
  • Options
    I agree with what you're saying, but the internet is used by two types of people: 1. Those who know the ropes 2. Those who don't The right click menu in IE or CTRL in Firefox are all well and good, but how about just regular usability? Websites should give a variety of users a suitable interface. Shame its so complicated!
  • Options
    when doing field tech support, as a matter of course i'd install firefox on people's computers (usually right after a 30 minute session of vigorously disabling spyware). convincing someone to use something that is new and different but ultimately better for them is always a tricky process.

    i learned after the first time i had to educate a user on firefox that tabbed-browsing is *absolutely* a power-user mechanism. it blows people's minds.

    and i agree... letting the user decide is always best, i was just curious if there was a "proper" way to do it, if it had to be done.
  • Options
    This simple javascript opens all external links in _blank function outLnk() { if(!document.links) return; for (i = 0; i < document.links.length; i++) { var lnk = document.links[i]; if (lnk.href.match(/^(http|https)/) && (lnk.href.indexOf(location.hostname) == -1)) { lnk.setAttribute('target', '_blank'); }}} window.onload = function() { outLnk(); } HTH
  • Options
    Mark - middle click does the same as CTRL+click. At least it always has for me. Add that to mouse gestures, and I'm a happy browser. Any browser without gestures is NOT a browser pour moi.
  • Options
    blizeHblizeH ✭✭
    edited June 2006
    I'd suggest option #3 too.
  • Options
    http://www.456bereastreet.com/archive/200605/using_javascript_instead_of_target_to_open_new_windows/
  • Options
    ithcyithcy New
    edited May 2006
    14. 2006-05-03, 4.08 by Lachlan Hunt

    Regardless of that, opening a new window for a PDF or any other format is wrong because you don't know how the user has configured their browser and the external application. PDFs, for example, may load within the browser window, they may be saved to disk or they may launch an external application. Opening a new window for all but the first scenario will typically result in an new blank browser window.

    I know I've said this many times before, and I'm sure it'll come up many more times in the future: There are no valid use cases for opening a new window


    15. 2006-05-03, 4.37 by Lachlan Hunt

    Oops, I take that comment back about no valid use cases for opening a new window. I'm pretty new at this web programming thing and have only created a few home pages and a myspace profile. So, I will hopefully discover more uses for this new window thingy later on.
    priceless
  • Options
    edited May 2006
    Ahahahahaha. Though, having considerably more experience in web development, I can't say I really disagree with him.
  • Options
    edited June 2006
    "Actually, using the target attribute to open links in a new window is not standard-approved."
    target= is out of the XHTML 1.0 strict.
  • Options
    edited June 2006
    See the Jakob Nielsen's Top Ten Web Design Mistakes of 1999.

    I quite agree with this article. The average user doesn't always realised a new windows had been opened and he is quite frustated when he can't use the back button.

    That is an issue as well with some redirect fonctions and some use of ajax...

    Let people open links in a new windows or a new tab by themself is the best thing to do...


    But when I have to create this kind of link I do like that:

    myjs.js:
    function winOpen(URL, windowName, width, height, resizable, location, menubar, scrollbars, status, toolbar){ var windowFeatures; windowFeatures = ''; if (width != '' && width != null){ windowFeatures = windowFeatures+'width='+width+','; } if (height != '' && height != null){ windowFeatures = windowFeatures+'height='+height+','; } if (resizable){ windowFeatures = windowFeatures+'resizable,'; } if (location){ windowFeatures = windowFeatures+'location,'; } if (menubar){ windowFeatures = windowFeatures+'menubar,'; } if (scrollbars){ windowFeatures = windowFeatures+'scrollbars,'; } if (status){ windowFeatures = windowFeatures+'status,'; } if (toolbar){ windowFeatures = windowFeatures+'toolbar,'; } popupWindow = window.open(URL, windowName, windowFeatures); popupWindow.focus() } function ext(){ winOpen('', 'ext', 552, 400, true, true, true, true, true, true) }
    mypage.htm:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> ... <script language="javascript" src="myjs.js" type="text/javascript"></script> ... </head> <body> ... <a href="http://lussumo.com/" onclick="ext()" target="ext">Lussumo.com</a> ...

    That is still intrusive but that works for users with js disable and that the page will be be open in a little windows for other users.
This discussion has been closed.