I have a modal dialog window. Is there any event (or way) how to know when window is opened first time (not refresh, not postBack etc)? It is necessary for clearing cookie.
Asked
Active
Viewed 179 times
-2
-
@Andrew Peacoc,I need to clear cookie, say, with name "SelectedNode" when window is opened or closed – andDaviD Jul 12 '12 at 14:31
-
Why not just have a JS flag variable that indicates whether it's been opened before? Initialize it to `false`, then flip it to `true` when the modal dialog is opened. Page refreshes and postbacks will reload the page and set the variable back to false on its own. – Zhihao Jul 12 '12 at 14:35
-
@Zhihao, i need do it on the modal dialog window event. I don't know from where this window will be opened. – andDaviD Jul 12 '12 at 14:37
-
@andDaviD can you set the flag as a global variable (for the page)? Maybe I'm not understanding correctly, but from what I'm imagining you only need to know *when* the event was triggered, and not from *where*. – Zhihao Jul 12 '12 at 14:43
-
use sessions, set some session variable first time and check if set it mean reloaded or postback else first visit – Arif Jul 12 '12 at 14:43
-
@Zhihao, I edited one control, that is located in one microsoft dll. It consist of 3 elements. One of them is a button which opens new dialog window. I redirect the url of this button to my own window. So, when this window is opening I need to clear cookie. But this control from microsoft dll can be created anywhere on my site. – andDaviD Jul 12 '12 at 14:50
2 Answers
0
I assume you are the one coding the 'opening window' behavior. Why not store some variable (flag) that indicated whether the windows has been opened before or not? This can be a normal veriable or a session, cookie, local storage, etc. for long term storage.

Bas Slagter
- 9,831
- 7
- 47
- 78
-
I don't know from where this window will be opened. And the instance of this modal dialog isn't created by me. It is created in one microsoft dll. – andDaviD Jul 12 '12 at 14:39
-
Well...there must be some point where you can interact with the window or where you tell it to open. Otherwise...your're stuck. – Bas Slagter Jul 12 '12 at 14:44
0
If the just the cookie is your concern,
then change the cookie key(if you want to discard old cookie) or
don't set any expiration time for you cookie(if you want it not be sent with next fresh request) as default is session

techBeginner
- 3,792
- 11
- 43
- 59