Hello everyone. I have a web app that launches from an online portal into a new browser window. Everything works out fine until I try to open a new window or close the window from the webapp. Everything works fine when I test it locally though.
From what I've understood so far, after some Googling, it seems that this is because you can't call client side code from server side, for security reasons. I'll post what I've tried to implement for the Open and Close functions below:
Open
String javaScript = "window.open('http://www.google.com', null, 'height=555,width=760,
status=yes,toolbar=no,menubar=no,
location=no, scrollbars=yes');";
ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", javaScript, true);
Close
<a href="javascript:window.open('','_parent','');window.close();">Close Window</a>
as well as a simple
<a href="JavaScript:window.close()">Close</a>
in the HTML itself.
I know this question has been asked countless times before, but I've gone diving in the forums and Google and still can't find something that works, so I appreciate any help in this.
For now I'm suspecting that the problem lies in trying to call a pop-up window from another pop-up window for the Open function, while for the Close function, the server does not recognize the handle of the window that opened the pop-up.
Edit:
My apologies to everyone if I didn't make myself clear enough. I'll try to explain in more detail here.
Basically, in my web application, I have these 2 buttons, Open and Close.
The Open button will open up a link to another website in a brand new browser window.
The Close button will close the browser window that the application is residing in.
When I tested it out locally, i.e. localhost:xxxxx/Game.aspx, everything works fine. However, the app currently does not reside in a separate pop-up window called from another browser window
On the test server, the application is launched into a new browser window from an online game repository portal.
So just to re-illustrate the way I want it to work:
1. User logs into game repository page
2. User chooses a game to play
3. Game pops up in a new browser window
4. When user clicks on Open button, another new window pops up to a specific website(Does not work)
5. When user clicks on Close button, the game window closes itself(Does not work)
I hope this makes the issue clearer. Thanks.