Reputation:
It is possible to have an anchor tag have a different "href" attribute when javascript is not enabled.
For Example:
Javascript Enabled:
<a href="#news">News</a>
Javascript Not Enabled:
<a href="news.html">News</a>
Upvotes: 0
Views: 79
Reputation:
You can add the javascript enabled attribute in a data-xxxx
, and then use javascript to replace the href
with data-xxxx
.
For example, in HTML you could use
<a href="news.html" data-js-href="#news">News</a>
And in javascript, you could do
var links = document.querySelectorAll('a[data-js-href]');
for (var i=0; i<links.length; ++i) {
links[i].setAttribute('href', links[i].getAttribute('data-js-href'));
}
Upvotes: 1