Web development and useful information

Nathan's Blog

Bookmarklet: prevent clicks, form submissions, reloads and exits

I often mockup page changes using Chrome’s dev tools.
I’ll get a page just right, then later accidentally click a link or close the page and lose my changes.

page protect bookmarklet

This bookmarklet, once clicked will protect you from premature page exits.
It disables link clicks, form submissions, page reloads and exits.

Add it by going to this jsFiddle page, and dragging the green link to your bookmarks bar:
http://jsfiddle.net/R7QKP

Here’s the JavaScript:

javascript:window.onclick=function(){return false;},
window.onsubmit=function(){return false;},
window.onbeforeunload=function(){return 'Page Protection is enabled';};

Previous

How to protect your HSBC Secure Key

Next

Bookmarklet: show Twitter Bootstrap columns

1 Comment

  1. Looks good. At least users can save time and energy instead of repeatinge everything from scratch with just a wrong click. This is really a helpful code snippet, thanks :)

Leave a Reply to Ernie@Laptop Repairs Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Powered by WordPress & Theme by Anders Norén