# catch-links **Repository Path**: mirrors_jackmoore/catch-links ## Basic Information - **Project Name**: catch-links - **Description**: intercept local link clicks on a page - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-01-12 - **Last Updated**: 2026-03-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # catch-links intercept local link clicks on a page This is useful for doing client-side pushState UIs. # example Given some html: ``` html
aaa
bbb
cc
npmjs
``` We'll intercept the relative links `/a` and `/b`, printing them. The external link to npmjs.org will go through as usual. ``` js var getLocalLink = require('catch-links'); window.addEventListener('click', function (e) { const anchor = getLocalLink(e); if (anchor) { e.preventDefault(); console.log(anchor.href); } }); ``` # methods ``` js var getLocalLink = require('catch-links') ``` ## getLocalLink(event) Returns the anchor element if the anchor element is clicked and has an in-server url. # install With [npm](https://npmjs.org) do: ``` npm install catch-links ``` Use [browserify](http://browserify.org) to bundle this library into your project. # license MIT