I'm tying in to the onbeforeunload
event in Javascript to disable control of the page during the unload process. We have a bunch of users who were editing data during this time and it was wreaking havoc on the product.
There are a bunch of links that show up on the page that have href="javascript:....."
.
Clicking these links fires the disabling code, which makes the page impossible to use. Is there a way I can detect if the onbeforeunload
event is navigating to a different page or just firing this Javascript?
Have every href link visit a piece of javascript code which does inspection on the href contents before it is executed.
event.target.href.startsWith('javascript')
If yes, submit the request, if not, do something else.
这不是最可靠的检查方法,但它适用于我的目的:
$('*:focus').attr('href')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.