You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
i think the last three issues are not possible.because from server we can't able to access the javascript objects/variable and viceversa.if you are trying to close parent window from child window then it prompts , for this issue i searched in lot of sites but all of them told that it is not possible.For the first issue we can able to assign the variable to javascript session variable.but it may not work in other browsers except IE.
To close a browser window in Javascript you use the:
Code:
window.close()
method. This will close any window that you created (as a web designer) usually with the
Code:
window.open("","","")
method. If the browser window was opened by the user via a shortcut or icon on their machine (say on their desktop) then the browser will always prompt the user to confirm whether or not to close the browser.
--------------------
:) James Sellwood :)
--------------------
Very interesting trick to close a window without a prompt. I'll try it. (I'll also bet that the browser developers will fix this loophole in the future.)
Anyway, back to the original post:
1. Technically, you can't. On the client side, there is no access to session state or to anything on the server. See answer to #2.
2. (How is this different from #1?) The only way to pass values back to the server is via an HTML form element. So, you might try to use <INPUT TYPE="HIDDEN" ID="myvalue" runat="server" .../> and in your script you set the value of the "myvalue" element to whatever you want to pass back to the server. On the server, in the Page_Load handler (or wherever you like) you can then access the myvalue.Value property and get the value.
3. Not sure what you mean by this. I think I have answered it in #2.
4. See other replies.
quote:Originally posted by oreolla
Well, not always ;)
Here is a trick:
Code:
function tricky_win_close() {
window.opener = top;
window.close();
}
this trick works great with ie5.5 and above...but not with the version of internet explorer which is included in win98 (i guess that's ie4??). Does anybody have a clue how to get this done on a win98 machine?
Hey Haroldd, Harold (Harry) here;
Thanks a lot!
Works great;
I was stuck on this one all morning trying to get rid of that prompt.
I needed to open my main page with control over chrome so I created a script page that does this. When I tried to automatically close said page I was surprised to see I could not do it transparently.
It just made the whole process look ... cheezey.
Thanks again;
Harry G.
p.s. this is first post here so if I've screwed thing up a bit please forgive.
Quote:
quote:Originally posted by oreolla
Well, not always ;)
Here is a trick:
Code:
function tricky_win_close() {
window.opener = top;
window.close();
}
quote:Originally posted by oreolla
Well, not always ;)
Here is a trick:
Code:
function tricky_win_close() {
window.opener = top;
window.close();
}
Hi,
It is simply excellent. It works excellent with only one window open. Now I have a problem more here. I want to open another window first and then close the main window. When I try to close the main window ONLY, it is closing my child window also, which I don't want. Is there any way to keep my child window open and close only main window??