none
Open link in background when anchor's attribute "href" contains javascript RRS feed

  • Question

  • Hi community,

    I support web enterprise-level application with some legacy parts, where some windows are opened by using window.open command inside of anchor's href attribute. (e.g. <a href="javascript:MyFunction('../someurl', '2')" ../> ... function MyFunction(url, id) { window.open(url, id) ...)

    Now I have to open link in the background by pressing ctrl + click (or middle click), but for IE (9, 10, 11) it always becomes focused.

    Are there any ways to open those new tabs in the background (only when ctrl is pressed)? 

    P.S. I know that it would be better to provide actual link inside of href attribute, but unfortunatelly I don't have such options, due to application specific.

    Thank you in advace for your help!

    Monday, February 2, 2015 4:12 PM

All replies

  • Hi,

    scripted window outcomes depend upon your IE security zone settings, IE popup blocker settings, third party popup blocker addon settings and the security zone that the parent page is mapped to.
    var win=window.open('evil.htm');
    win.blur();

    window.focus();

    by default 'popunder' windows are prevented from links on pages in all IE security zones.

    Post questions about html, css and scripting for web site development to the IE sections at http://stack-overflow.com Include with your questions a link to your website or a mashup that reproduces your issue.

    Regards.


    Rob^_^

    Monday, February 2, 2015 11:53 PM
  • Hi Rob,

    thank you a lot for reply!

    I think mine issue not related to security and popup blocker settings. What I try to achieve is similar behaviour as we have for links (<a>) with href attribute fullfilled with actual url. Specifically

    * by single click new tab should be opened focused (this is fine)

    * by shift + click it should be opened in new browser window (this is also fine)

    * by middle (ctrl + click) new tab should be opened in background. This feature doesn't work well, because new tab alway opens focused and this is what I'm trying to fix, or at least find official proof that IE works in this way with javascript inside href attribute

    Here is example:

    http://jsfiddle.net/hj3gud9j/

    It works as expected in chrome but not in IE

    Yours sincerely, 

    Eugene Novykov


    • Edited by Eugene New Tuesday, February 3, 2015 7:28 AM
    Tuesday, February 3, 2015 7:27 AM
  • * by middle (ctrl + click) new tab should be opened in background. This feature doesn't work well, because

    It's not well documented but, depending on your choice in Tab Settings for Always switch to new tabs when they are created,  you need to also press Shift- with your Ctrl- to create a background tab.

    Here is example:

    Ironically that crashes the tab.  I am currently experimenting with EPM mode and 64-bit tab tasks.  YMMV.



    Robert Aldwinckle
    ---

    Tuesday, February 3, 2015 7:12 PM
    Answerer