KentZhou
KentZhou

Reputation: 25553

How to open new browser window for popup?

Following Javscript can open popup:

window.open('http://www.google.com','mywindow','width=400,height=200');

If call it two times like:

window.open('http://www.google.com','mywindow1','width=400,height=200');
window.open('http://www.google.com','mywindow2','width=400,height=200');

The later will override previous only one popup. I want to two separated windows for popup at sametime with above code. even I set different reference name like mywindow1, mywindow2.

How to fix this problem?

More info:

The way I call js in code-behind is:

string js = "<script language=javascript> window.open("myurl1","_blank","DialogWidth=700;DialogHeight=750;left=30;top=30;");</script>";
Response.Write(sUrl);

js = "<script language=javascript> window.open("myurl2","_blank","DialogWidth=700;DialogHeight=750;left=30;top=30;");</script>";
Response.Write(sUrl);

It looks like later close the previous window.

Upvotes: 1

Views: 3022

Answers (2)

T.J. Crowder
T.J. Crowder

Reputation: 1074276

It shouldn't, you should get a new window because the window names are different ("mywindow1" vs. "mywindow2"). Do you really need to name the windows? If not, try "_blank" instead. If you're not putting the digits on the end, that's your problem — using the same window name reuses the window (by design).

Upvotes: 0

David
David

Reputation: 7153

window.open('http://www.google.com','_blank','width=400,height=200');
window.open('http://www.google.com','_blank','width=400,height=200');

See MSDN documentation.

Upvotes: 1

Related Questions