Search code examples
javascriptwindownew-operator

Open a completely new window with JavaScript without replacing the contents of the previous window


I have a page with several links that open a separate window with varying content. My goal is to open a window for each and every such link using JavaScript. My problem is as follows:

let's assume: - i have two links on the page, lnkDoWorkOne and lnkDoWorkTwo - lnkDoWorkOne opens a window with url = WorkOne.aspx which in turn does some work upon loading - lnkDoWorkTwo opens a window with url = WorkTwo.aspx which also does some work

In my present solution when I click lnkDoWorkOne then a new window opens with WorkOne.aspx and works just fine. Then when I click lnkDoWorkTwo, then there's no new window at all but the contents of the previously opened window are simply replaced by WorkTwo.aspx. I need to have BOTH windows open with WorkOne.aspx and WorkTwo.aspx so that the user can view the contents in parallel.

Does anyone know how to achieve this?


Solution

  • Are you giving the same window name to the both window.open calls? If so, change the name of the window and you should get two separate windows.

    window.open('WorkOne.aspx', 'window1');
    ...
    window.open('WorkTwo.aspx', 'window2');