javascript - Use onclick event when JS is enabled, navigate to a URL when it's not -


In order to keep load time down, Facebook uses Ajax link to replace parts of your page. But if you disable Javascript, their links still work because the reason they have defined the backup option is: classic & lt; A href = "http: // url /" .

How can I apply this myself so that when JS becomes disabled and when JS is enabled then onclick event is used, then the link will be followed? Your onclick in

Code> return false; , which in this case is actually navigating to the URL, something like this:

  document.getElementById ('linkId'). Onclick = function () {Warning ("Go to this link:" + this.href); return false; };  

Or, if you are using something like jQuery and:

  $ ("a"). Click (function (e) {alert ("This link will go to:" + this.href); Return back; // or e.preventDefault ();});  

Comments