On my parent page I added a script which ask confirmation befor page unload (On every button press) using window.onbeforeunload, The problem i use to open a subPage on this parent page, and on closing of开发者_JAVA技巧 the subpage i use to reload the parent page, but it ask confirmation and I dnt want that....
Any help will be really appreciated
Thanx
How about...
- In the main page, creat a new variable, called 'confirmUnload', set it to 'true' by default.
- In the beforeUnload function, check the state of this variable before deciding whether to ask for confirmation or not.
- Add a new function called 'refreshWithoutConfirmation' and have this set the variable to 'false' before refreshing the page.
- Have the sub page call 'refreshWithoutConfirmation' instead of refreshing the page directly.
Not tested this, but it seems workable to me.
Before calling reload
, set a flag.
In onbeforeunload
, check the flag, and, if it's true
, return null
.
Add a flag variable on parent page. If it true, ask the confirmation. If false, do not ask.
When you close the subPage and before reload the parent, set this flag to false
精彩评论