Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.open doesn't open in same session

I'm using the below anchor tag on a JSP page to open another page from the same application, but the new window is not opened in the same session and instead it redirects to the login page of my application. Any clues why?

<a href="#" onclick="window.open('/path_to_same_page', '_blank',
        'toolbar=0,status=0,resizable=1'); return false;">Click here...</a>
like image 788
Karthik Murugan Avatar asked Jul 05 '11 09:07

Karthik Murugan


People also ask

Does window open create a new session?

Its also a matter of fact the window. open creates a new window that shares session cookies.

Is window open synchronous?

Using Chrome's window. open() allows synchronous access to opened windows so it is convenient choice if you need to open a dialog or a preferences window.

How do you check if the window is already open in JavaScript?

How to check if an opened browser window is closed or not in JavaScript? To check if an opened browser window is closed, you can use the closed property in referenced window object in JavaScript. The property returns a boolean true if the window is closed and false if the window is in the opened state.


1 Answers

Try this workaround, not sure it will help but worth a shot:

<a href="/path_to_same_page" target="mywindow" onclick="window.open('/path_to_same_page', 'mywindow', 'toolbar=0,status=0,resizable=1');">Click here...</a>

By having this, the window won't get opened by script initially, but rather by the target attribute.

like image 128
Shadow Wizard Hates Omicron Avatar answered Oct 29 '22 07:10

Shadow Wizard Hates Omicron