LastPass Chrome extension throwing error and preventing click events
google-chrome, google-chrome-extension, javascript, lastpass
Solution
[Uplifted from my comment on suggestion of Muhamed Cicak and to draw more prominence.]
Lastpass has a 'Never URLs' option on the account admin page where you can tell it to ignore a URL - useful if you want Lastpass awake but not start interfering with your forms.
To access it:
- Open your Lastpass vault
- Open Account Settings
- On the top of the window there is a list of options - select 'Never URLs'
- There are options for 'Never Add Site', 'Never Fill Forms' and 'Never Do Anything'. Use the Add button to add a URL.
[EDIT] Additionally there is an accepted answer for page authors in a SO answer here which says to add
data-lpignore="true"
to tell lastpass to ignore it.
Problem
I'm registering a simple click event like seen below: ``` $('.block--hero').on('click', '*[data-target-id]', function(e) { e.preventDefault(); e.stopPropagation(); console.log('clicked'); }); ``` Frequently, but not always, when I click on the interface element, I'll receive the following console error that I've identified as belonging to the `LastPass` extension for Google Chrome. ``` Uncaught TypeError: Cannot read property 'location' of undefined onloadwff.js:726 lp_docinfoFromEvent onloadwff.js:726 icon_click_handler onloadwff.js:727 (anonymous function) onloadwff.js:139 ``` When I receive this error, the `clicked` message wasn't logged to the console. Essentially, the click event returned `false`. Normally, I'd just disable the extension and forget about it, but `LastPass` is a pretty popular extension, and I'd like to somehow guarantee my intended behaviour. Users aren't going to know it's their extension causing the problem - only that the site doesn't work. Is there a way around this?