New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

stay-or-go

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stay-or-go

Determine if an anchor click was intended for staying on the current site

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

stay-or-go

Determine if an anchor click was intended for staying on the current site.

build status dev dependency status

browser support

Example

The function this module exposes should be used in a click handler:

var stayOrGo = require('stay-or-go');

window.addEventListener('click', function (evt) {
  var a = stayOrGo(evt);
  if (!a) return;

  evt.preventDefault();

  history.pushState(a.pathname, '', a.pathname);
}, false);

If one or more of the following is true the return value will be undefined:

  • The default action of the event was already prevented (event.preventDefault()).
  • The user did not click the normal mouse button (when using a mouse).
  • The user held one of the Ctrl, Shift, or Meta keys when clicking.
  • The user did not click an anchor or a child elemnt of an anchor.
  • The anchor clicked has a target attribute.
  • The href of the anchor is pointing to an external site.

Otherwise the return value is the anchor element clicked.

License

MIT

Keywords

browser

FAQs

Package last updated on 13 Oct 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts