Giter Site home page Giter Site logo

chihyanglee / backspace-disabler Goto Github PK

View Code? Open in Web Editor NEW

This project forked from slorber/backspace-disabler

0.0 1.0 0.0 10 KB

Disable the annoying browser backward navigation when the user press the backspace key

License: MIT License

JavaScript 100.00%

backspace-disabler's Introduction

BACKSPACE DISABLER

Disable the annoying backward navigation that occurs when the user press the backspace key.

Features

  • Prevent browser back on backspace (by using preventDefaut())
  • Does not break ability of user to delete content on all known input types
  • Supports contentEditable (in read/edit mode)
  • Allow to apply the behavior globally or on a subtree
  • No dependency

Installation

NPM:

npm install backspace-disabler

Or just copy the code inside index.js into your codebase.

Usage

Require it with CommonJS loader (Browserify / Webpack...)

var BackspaceDisabler = require("backspace-disabler");

// Disable the backspace that triggers backward navigation
BackspaceDisabler.disable(); 
// Revert to normal
BackspaceDisabler.enable();

// Can also be applied to a specific element tree:
var myWidget = document.getElementById("myWidget");
BackspaceDisabler.disable(myWidget);
BackspaceDisabler.enable(myWidget);

Credits

The ideas of this lib come from StackOverflow

Hire a freelance expert

Looking for a React/ReactNative freelance expert with more than 5 years production experience? Contact me from my website or with Twitter.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.