catch-links

intercept local link clicks on a page

npm install catch-links
1 downloads in the last week
10 downloads in the last month

catch-links

intercept local link clicks on a page

This is useful for doing client-side pushState UIs.

example

Given some html:

<html>
  <body>
    <div>
      <a href="/a">aaa</a>
    </div>

    <div>
      <a href="/b">bbb</a>
    </div>

    <div>
      <a href="http://npmjs.org">npmjs</a>
    </div>

    <script src="bundle.js"></script>
  </body>
</html>

We'll intercept the relative links /a and /b, printing them. The external link to npmjs.org will go through as usual.

var catchLinks = require('catch-links');

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

methods

var catchLinks = require('catch-links')

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

install

With npm do:

npm install catch-links

Use browserify to bundle this library into your project.

license

MIT

npm loves you