krazylek / a-catcher

Intercept click on html links

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

a-catcher

Intercept click on <a href=""> local links, usefull for single page app.

The code is extracted from Sheet-router/href.js and catch-links.

All credits are due to Yoshua Wuyts and James Halliday

The goal of this module is to be self-contained and avoid the url module dependency.

The signature is similar to catch-links.

Example

const catchLinks = require('a-catcher');

catchLinks(window, function (href) {
  console.log(href);
});

methods

var catchLinks = require('a-catcher')

catchLinks(element, cb)

Fire cb(href) whenever an anchor tag descendant of element with an in-server url is clicked.

install

With npm do:

npm install a-catcher

license

MIT

About

Intercept click on html links

License:Other


Languages

Language:JavaScript 100.0%