1

For some of you this question may seem to be stupid, but I don't think so...

So, basically what I want to achieve is to open new tab by javascropt in the same browser window, but it mustn't be opened by clicking on something. I've tryed several things...

window.open(url,"_blank") somehow doesn't work for google chrome, it opens whole new window of chrome...

then I tried something like this

`<a href="" target="_blank" id="link"></a>

<script type="text/javascript">
    function OpenNewTab(link){
        var a = $('a[target="_blank"]')[0];
        a.setAttribute('href', link);

        // document.getElementById("link").click();
        // a.click();
    }
</script>`

anyways if I comment out any of the lines, it still does the same, but if I change first line of code to this

`<a href="" target="_blank" id="link">Click Here</a>`

and click it, it of course works fine...

as a reminder, all this things apear to be working for me on firefox

Note: don't forget that all I want is to open tab after something happens in my code, not after user clicks on something

Ratty
  • 37
  • 1
  • 7
  • after what happens in your code – hahaha Jul 25 '14 at 10:58
  • I just want to call my function after I resieve some event from server into flash, from flash I can call javascript functions, and by this function I what to open a tab – Ratty Jul 25 '14 at 11:06

1 Answers1

0

Check this very informative answer here might help you find out why it does that, and if possible overcome it. Basically what is happening, how it's designed to work, if the user started an event, (knocked down the first domino) the link will open in a new tab, otherwise it will open in new window.

a little demonstration of this here

$('#test').click(function(){
    //take control!
    GodsOpenNewTab('http://www.google.com');
    knockDomino('http://www.bing.com');
});

EDIT: I guess if you have the information in your flash you could open the new tab directly from there, and hopefully it will be a tab and not a window!

Community
  • 1
  • 1
hahaha
  • 1,001
  • 1
  • 16
  • 32
  • from flash I can call window.open, or any javascript function, so it effects like normal javascript, and I think I cannot do anything beyond that, anyways thanks for answering me – Ratty Jul 25 '14 at 11:55
  • I don't know much of flash but am 99% sure you can open a new tab with a flash script or something! :) – hahaha Jul 25 '14 at 12:59
  • Flash has ExternalInterface class by which you can call javascript function, that's what I do when I want to open new tab, ExternalInterface.call("window.open",url,"_blank", WindowSizeParams); – Ratty Jul 25 '14 at 13:28