Skip to content

jhnns/nanohref

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nanohref stability

npm version build status downloads js-standard-style

Tiny href click handler library.

Usage

var nanohref = require('nanohref')

nanohref(function (location) {
  console.log('new location is', location.pathname)
})

// Create DOM node
var el = document.createElement('a')
el.setAttribute('href', '/my-link')
el.innerText = 'Click me'
document.body.appendChild(el)

// Trigger click
el.click()
// => "new location is /my-link"

API

nanohref(handler(location), [rootNode])

Create a new anchor click handler. The second argument is for the root node, which defaults to window.document. If the data-no-routing attribute is set, Nanohref will not handle the link. This is useful to link to resources outside the application.

License

MIT

About

Tiny href click handler library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%