Monday 8 February 2016

how to detect if JavaScript is disabled in browser.

javascript disabled in browser
Description:-

In this example we explain that how to detect if JavaScript is disabled. Or how to check JavaScript is enabled or disabled in your browser using JavaScript.

We all know in every application JavaScript greatly enhance the experience for the user whether it is validate from data or modal popup or anything. Sometime what happen when some users don’t have JavaScript enabled in their browser so your JavaScript functionality is not worked properly for those user so point is that you need to be able to detect this and display proper message like JavaScript is not enabled in your browser please enabled it to perform this action.

Below is the code for if JavaScript is disabled in your browser you can easily display warning message to the user by adding “noscript” tab.


Code:-

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="javascriptdisabled.aspx.cs"
    Inherits="WebApplication1_javascriptdisabled" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>Detect Javascript On/Off, With Notification</title>
    <script type="text/javascript">
        function popUp() {
            alert("This is an popup alert")
        }
    </script>
</head>
<body onload="popUp()">
    <p>
        You should see a pop-up.</p>
    <noscript>
        <p>
            But unfortunately, Javascript is disabled in your Browser . Please enable it.</p>
    </noscript>
</body>
</html>



1 comments:

  1. Thought-provoking suggestions - Coincidentally , if your business have been needing to merge two PDF files , my company found a service here http://goo.gl/Ms4ebj

    ReplyDelete