Javascript – Can we use 2 different url on same anchor tag for javascript disabled and enabled condition

cssjavascriptjqueryxhtml

Can we use 2 different url on same for javascript disabled and enabled condition

If javascript is enabled then link should be <a href="link1">

and If javascript is disabled then link should be <a href="link2">

Best Solution

You could set the JS disabled URL in the markup, then on page load use JS to replace the url with the enabled URL.

HTML:
<a id="id" href="js_disabled_url" />Link</a>


jQuery example:
$(function() {
    $('#id').attr('href','js_enabled_url');
});

This should degrade gracefully.