html5 - Alternative Anchor Tag For When Javascript Is Not Enabled -


it possible have anchor tag have different "href" attribute when javascript not enabled.

for example:

javascript enabled:

<a href="#news">news</a> 

javascript not enabled:

<a href="news.html">news</a> 

you can add javascript enabled attribute in data-xxxx, , use javascript replace href data-xxxx.

for example, in html use

<a href="news.html" data-js-href="#news">news</a> 

and in javascript, do

var links = document.queryselectorall('a[data-js-href]'); (var i=0; i<links.length; ++i) {     links[i].setattribute('href', links[i].getattribute('data-js-href')); } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -