HOW TO detect if a browser supports Javascript & it is ENABLED.

The Request.Browser property which is an instance of the HttpBrowserCapabilities object can be used to determine browser information using ASP.NET.

The BrowserCapabilities object contains properties that describe the features available in a particular browser.

Request.Browser.JavaScript property returns either true or false depending on its availability in the browser.

A user having a Javascript supported browser may opt to disable it. How to detect that?

One technique to determine if a user has JavaScript enabled is to create a HIDDEN form field in the HTML and call a JavaScript function on the ONLOAD page event, altering the value of this HIDDEN form field. That way, if the form field has been altered, then we know JavaScript is enabled (else the JavaScript function that alters the HIDDEN form field wouldn't have been called).

Update: You can prevent a web application from breaking in a case where there is some dependent functionality built with Javascript & the user has disabled Javascript in her browser. Check this - "HOW TO handle users who disable Javascript in their browser"

Comments