I am currently working on a project that involves displaying a series of resources on a web page. Each resource is stored as a record in a database with two fields: "url" and "visited."
One issue I have encountered is that when a user clicks on a resource's URL, the "visited" field is updated to true in the database via an AJAX PUT request. However, if the user decides to open the URL in a new tab, this event is not captured by the JavaScript and the database record remains unchanged.
I came across a discussion on Stack Overflow suggesting to switch from using a "click" handler to an "onmousedown" handler. Unfortunately, this approach only captures the opening of the context menu, even if no action is taken.
Is there a standard method for handling the "open in new tab" event effectively?
Any insights or suggestions would be greatly appreciated!