I have an HTML link and I want to take some action when the user leaves it, but only if the user moves forward through the document and not backward.
Is there a reliable cross-browser way to determine how a user navigates a document, or is it really, if at all, tabooing a document? I am attached to the blur event, but this does not necessarily mean that the user is tabbing.
I looked at checking the value of document.activeElement or the hasFocus attribute of a previous custom item in the source, but:
- this is similar to relatively recent additions and therefore may not be widely supported, and
- I am not sure that they will be checked when the
blur event occurs, since even if the user is tabbing, I do not think that the next element will be focused.
source share