I'm using JavaScript to allow users of my site to click anywhere on a table row to visit the URL of the row's record. Setting location.href works fine except that when my users try to open the page in a new tab behind the current one, JavaScript breaks their browsers normal Shift+Click behavior. How can I change the page with JavaScript without this nasty side-effect?
This is a browser behavior and you cannot replicate it in any way.
Many workarounds may be detecting the Shift keypress and executing window.open, or inserting an <a/> element that surrounds all of each cells content, and dinamically changing the href on mousedonw, but all are ugly patches.
This is one of many situations in which you face that javascript can do almost everything to manipulate the DOM, but not broswer actions that are commonly triggered when interacting with the DOM.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With