[removed] not working in chrome

后端 未结 9 808
遥遥无期
遥遥无期 2020-11-27 07:25

This is the code which i used for window.onbeforeunload......




        
9条回答
  •  一整个雨季
    2020-11-27 08:25

    Confirmed this behavior on chrome 21.0.1180.79

    this seems to work with the same restritions as XSS, if you are refreshing the page or open a page on same domain+port the the script is executed, otherwise it will only be executed if you are returning a string (or similar) and a dialog will be shown asking the user if he wants to leans or stay in the page.

    this is an incredible stupid thing to do, because onunload/onbeforeunload are not only used to ask/prevent page changes.

    In my case i was using it too save some changes done during page edition and i dont want to prevent the user from changing the page (at least chrome should respect a returning true or change the page without the asking if the return is not a string), script running time restrictions would be enought.

    This is specially annoying in chrome because onblur event is not sent to editing elements when unloading a page, chrome simply igores the curent page and jumps to another. So the only change of saving the changes was the unload process and it now can't be done without the STUPID question if the user wants to change it... of course he wants and I didnt want to prevent that...

    hope chrome resolves this in a more elegant way soon.

提交回复
热议问题