GithubHelp home page GithubHelp logo

josephdot / skip-link-focus Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cedaro/skip-link-focus

0.0 1.0 0.0 10 KB

Make "skip to content" links more accessible.

License: Other

JavaScript 56.26% HTML 43.74%

skip-link-focus's Introduction

Skip Link Focus

Make "skip to content" links more accessible.

Usage

Include skip-link-focus.js above the closing </body> tag and initialize it:

<script src="skip-link-focus.js"></script>
<script>skipLinkFocus.init();</script>

Or if you're using Browserify:

require( 'skip-link-focus' ).init();

init() takes an optional options argument:

  • options.selector {String} Specifies a DOM selector where skip links are to be found. This is used to handle an edge case where, if a hash is present in the URL on initial load (or refresh), clicking the skip link wouldn't actually fire a hashchange event, making the skip link unusable. Usage example: init( { selector: '.generic-skip-link-class' } ). Defaults to .skip-link.

Background

Makes "skip to content" links work correctly in IE9, Chrome, and Opera to improve accessibility.

Initial code and background can be found here:
http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/

Further improvements were made in the _s WordPress theme by Automattic.

This module is based on the _s implementation with the following enhancements:

  • Implemented the UMD pattern for use as an AMD, CommonJS, or stand-alone module.
  • Added a skip link click handler to fix cases when a hashchange event isn't fired because the address bar already has the corresponding hash.
  • Split the functionality into methods to provide a simple API.

Additional reading on skip link accessibility: https://www.bignerdranch.com/blog/web-accessibility-skip-navigation-links/

Testing

To manually test the script in a browser of your choice, run npm test and head to http://localhost:5000/test/.

skip-link-focus's People

Contributors

bradyvercher avatar backflip avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.