JavaScript and Cookies enabled question

Hi,

Hi, I have some code to display some things, please see the attached code and images to see what is happening the way things are coded now.

Can someone please give me some ideas on how to make this happen?

This is exactly what I am looking to do, just like this:
If JS and Cookies ARE enabled:
Display: Your broswer has met the requirements to use our service
Enable Login Button

If JS IS NOT enabled:
Display: JavaScript is not enabled CLICK HERE to learn how
Disable Login Button

If JS IS enabled and Cookies ARE NOT:
Display: Cookies are not enabled CLICK HERE to learn how
Disable Login Button

JS-NOT-enabled-but-Cookies-ARE.png
JS-and-Cookies-Enabled.png
Cookies-NOT-Enabled-but-JS-IS.png
demo.html
LVL 3
Computer GuyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gurvinder Pal SinghCommented:
try this
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<script src="jquery-1.4.2.min.js"></script>
		<script>
			$(document).ready(function(){
				$("#noJS").hide();
				if ( isCookieEnabled( ) )
				{
					$("#noCookie").hide();
					$("#success").show();
				}
			});
			function isCookieEnabled( )
			{
				var cookieEnabled = (navigator.cookieEnabled)? true : false;

				if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled)
				{ 
					document.cookie = "testcookie";
					cookieEnabled = ( document.cookie.indexOf( "testcookie" ) != -1 ) ? true : false;
				}
				return cookieEnabled;
			}
		</script>
	</HEAD>

	<BODY>
		<div id="success" style="display:none;color:green">Your browser has met the requirements to use our service</div>
		<div id="noJS" style="color:red">Your browser has met the requirements to use our service</div>
		<div id="noCookie" style="color:red">Your browser has met the requirements to use our service</div>
	</BODY>
</HTML>

Open in new window

0
Computer GuyAuthor Commented:
Hi Thanks!

Just one last question.

If JS is disabled, it also displays Cookies are not enabled too (Even though they are enabled, but since JS is disabled it thinks cookies are disabled too)

If JS is disabled, is there a way to just say JS is disabled and check for cookies when JS is enabled, so I only get 1 message at a time?
0
Gurvinder Pal SinghCommented:
replace line 6-13 by

$(document).ready(function(){
                        $("#noJS").hide();
                                $("#noCookie").hide();
                        if ( isCookieEnabled( ) )
                        {
                              $("#success").show();
                        }
                                else
                                {
                                        $("#noCookie").show();  
                        }
                           
                  });
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

khan_webguruCommented:
Hello Bro!


In the member area of my site I wanted to be sure that users had cookies and JavaScript enabled. Most member areas are rather complex as far as maintaining session state and form validation are concerned. You need fairly bullet proof ways to validate data. On my site I use client-side JavaScript form validation; therefore, for the validation to work, the user's browser must have JavaScript enabled. Also, I use Session variables, requiring that my visitors have Cookies enabled. To ensure that these preconditions are met, I use a nifty script to check that my users have both JavaScript and Cookies enabled; I simply do not allow users to log on if they do not have these two technologies enabled. In this article I am presenting the login page for my site.


In plain language to do this with client-side JavaScript code. We start by creating a Cookie using JavaScript and then checking to see if that Cookie exists. Since we use JavaScript to test if the user has Cookies enabled, if they don't have JavaScript enabled, but do have Cookies enabled, we'll get word back that they don't have Cookies enabled. This is fine, since I require that my users have both JavaScript and Cookies enabled. (If you are interested in if your users have just Cookies enabled (or disabled), check out this ASPMessageboard post: Checking for Cookies.) To determine if a user has JavaScript enabled, I 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). (Both the JavaScript and Cookie checks are handled in a single JavaScript function.)

To get started, first we'll need to place a HIDDEN field in our HTML, which we'll use to determine whether or not JavaScript is supported. Place this hidden field within <form> ... </form> tags. (This FORM could also contain a username/password if you require that sort of information for someone to login to your site.)



 
<FORM>
  ...
  <input type="hidden" name="cookieexists" value="false">
</FORM>

Open in new window



As long as the value of this field is false then we know that the user's browser does not support JavaScript. Note that it is false by default. Our JavaScript function will switch the value to true. Therefore, if JavaScript is enabled, the JavaScript function will run, and the value will be toggled to true. In your BODY tag place the code to call the JavaScript function that checks for cookies (cc()).



 
<body onload="cc()">

Open in new window



If the function does not execute (which will only occur if JavaScript is disabled), the cc() function will not change the value of the HIDDEN field. The code for the cc() function is rather simple.



 
<script language="JavaScript">
<!--
function cc()
{
 /* check for a cookie */
  if (document.cookie == "") 
  {
    /* if a cookie is not found - alert user -
     change cookieexists field value to false */
    alert("COOKIES need to be enabled!");

    /* If the user has Cookies disabled an alert will let him know 
        that cookies need to be enabled to log on.*/ 

    document.Form1.cookieexists.value ="false"  
  } else {
   /* this sets the value to true and nothing else will happen,
       the user will be able to log on*/
    document.Form1.cookieexists.value ="true"
  }
}

/* Set a cookie to be sure that one exists.
   Note that this is outside the function*/
document.cookie = 'killme' + escape('nothing')
// -->
</script>

Open in new window




Note that the line of JavaScript code outside of the function will execute before the page is loaded and, therefore, before the cc() function is called. As always, the JavaScript code block should be placed in the HEAD section of your HTML page.

At this point if JavaScript is enabled and Cookies are not, the user will have been alerted that he needs cookies enabled to proceed. If JavaScript is disabled of course no alert can be displayed. If JavaScript is disabled we can't really tell if Cookies are enabled or not. However, since I only let the user login if they have both JavaScript and Cookies enabled, it's no big deal if they have Cookies enabled but I can't tell. If JavaScript is disabled, however, I can't alert the user that they need to enable JavaScript (since an alert would require JavaScript code, which won't run on a user's browser if they have JavaScript disabled!). So what you can do is, when the form is submitted, check to see if the HIDDEN field cookieexists equals true or false. If it equals false then JavaScript is not enabled (and possible Cookies are also disabled, although we can't tell for sure with this method if JavaScript is disabled).

Happy Programming!

Hope this will help you

Regards,

Asif Ahmed Khan
0
khan_webguruCommented:
Hello bro!


For JAVASCRIPT enabled CHECK you can use this


 
<SCRIPT language="JavaScript"> 
<!-- BEGIN HIDING
 var browserName=navigator.appName; var browserVer=parseInt(navigator.appVersion); if ((browserName=="Netscape" && browserVer>=3) || (browserName=="Microsoft Internet Explorer" && browserVer>=4)) version="n3"; else version="n2"; if (version=="n3") alert("Your browser passes the test"); else alert("You need an upgrade, I think."); 
// DONE HIDING --> 
</SCRIPT>

Open in new window



or you can use noscript tag

 
<noscript>javascript in not enable <a rel="nofollow" href="http://www.nikeshyadav.com" target="_blank">click here</a> to rediect ur browser</noscript<

Open in new window



If you see my last post regarding COOKIE so merge this and previous concept you will able to implement both logics.

Regards,

Asif Ahmed khan
0
khan_webguruCommented:
Bro!

If you want to involve server side then follow the link below

"Check if JavaScript is Enabled from Server-Side Using an User Control"

http://www.codeproject.com/KB/user-controls/CheckJavascriptEnabled.aspx

Regards,

Asif Ahmed Khan

0
khan_webguruCommented:
Bro,

If you did not used <noscript> tag before so please find the detail below to understand that concept.

Check Browser Javascript enabled

JavaScript is a small, lightweight, object-oriented, cross-platform scripting language.JavaScript is used in millions of Web pages to add functionality, validate forms, detect browsers, and much more.With some reasons the web browser don’t support Javascript ,like user intentially disables,some mobile browsers version don’t support.Then it must we check the whether user’s web browser has Javascript enabled.Here we discuss how to handle non Javascript browser.
We show a alert ,warning message if user browser don’t hav Javascript enabled.using <noscript> HTML tag. just add bellow code to any where in the body section.<noscript> element will be rendered by those Javascript disabled browsers.


 
<noscript><font face=arial>JavaScript must be enabled in order for you to use maheshchari.com in standard view. However, it seems JavaScript is either disabled or not supported by your browser. To use standard view, enable JavaScript by changing your browser options, then <a href="">try again</a>. </font></noscript>

Open in new window



We show a alert ,warning message with Javascript itself if user browser doesn’t support <noscript> HTML tag.below example code demonstrates.


 
<div id="nojs"><font face=arial>JavaScript must be enabled in order for you to use maheshchari.com in standard view. However, it seems JavaScript is either disabled or not supported by your browser. To use standard view, enable JavaScript by changing your browser options, then <a href="">try again</a>.</font></div>
<script>
//if script enabled warning message hidden.
document.getElementById('nojs').style.display="none";
</script>

Open in new window



We create seperate UI or seperate web site for those Javascript disabled browsers. below example redirects the user automatically if Javascript disabled.


 
<html>
<head>
<noscript>
<meta http-equiv="refresh" content="0;URL=http://mobile.maheshchari.com" />
</noscript>
</head>
<body></body>
</html>

Open in new window


Thats all from my side. best of luck.

Regards,

Asif Ahmed Khan
0
khan_webguruCommented:
Hello Bro!

@gurvinder372 solution is good but for this you have to relay on JQuery I used in my all posts "JAVASCRIPT" with no third party api.

Both ways are correct. Its up to which you want to use.

Regards,

Asif Ahmed Khan
0
Computer GuyAuthor Commented:
Still shows cookies are disabled (even though they are enabled) if JS is disabled
<script src="jquery-1.4.4.min.js"></script>
		<script>
$(document).ready(function(){
                        $("#noJS").hide();
                                $("#noCookie").hide();
                        if ( isCookieEnabled( ) )
                        {
                              $("#success").show();
                        }
                                else
                                {
                                        $("#noCookie").show();   
                        }
                            
                  });

			function isCookieEnabled( )
			{
				var cookieEnabled = (navigator.cookieEnabled)? true : false;

				if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled)
				{ 
					document.cookie = "testcookie";
					cookieEnabled = ( document.cookie.indexOf( "testcookie" ) != -1 ) ? true : false;
				}
				return cookieEnabled;
			}
		</script>

Open in new window

0
Gurvinder Pal SinghCommented:
try this
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<script src="jquery-1.4.2.min.js"></script>
		<script>
			$(document).ready(function(){
				$("#noJS").hide();
				if ( isCookieEnabled( ) )
				{
					$("#noCookie").hide();
					$("#success").show();
				}
				else
				{
					$("#noCookie").show();
				}
			});
			function isCookieEnabled( )
			{
				var cookieEnabled = (navigator.cookieEnabled)? true : false;

				if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled)
				{ 
					document.cookie = "testcookie";
					cookieEnabled = ( document.cookie.indexOf( "testcookie" ) != -1 ) ? true : false;
				}
				return cookieEnabled;
			}
		</script>
	</HEAD>

	<BODY>
		<div id="success" style="display:none;color:green">Your browser has met the requirements to use our service</div>
		<div id="noJS" style="color:red">Javascript is disabled</div>
		<div id="noCookie" style="display:none;color:red">Cookies is disabled</div>
	</BODY>
</HTML>

Open in new window

0
khan_webguruCommented:
Hello Bro!


Try This

 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <script language="JavaScript">
                <!--
        function cc() {
            /* check for a cookie */
            if (document.cookie == "") {
                /* if a cookie is not found - alert user -
                change cookieexists field value to false */             

                /* If the user has Cookies disabled an alert will let him know 
                that cookies need to be enabled to log on.*/

                document.getElementById("cookieexists").value = "false"
                return false;
            } else {
                /* this sets the value to true and nothing else will happen,
                the user will be able to log on*/
                document.getElementById("cookieexists").value = "true"
                return true;
            }
        }

        /* Set a cookie to be sure that one exists.
        Note that this is outside the function*/
        document.cookie = 'killme' + escape('nothing')
        // -->

        function isScriptEnable() {
            var browserName = navigator.appName;
            var browserVer = parseInt(navigator.appVersion);
            if ((browserName == "Netscape" && browserVer >= 3) || (browserName == "Microsoft Internet Explorer" && browserVer >= 4))
                version = "n3";
            else
                version = "n2";
            if (version == "n3") {
                if (cc()) {
                    document.getElementById("noJS").style.display = "none";
                    document.getElementById("noCookie").style.display = "none";
                    document.getElementById("success").style.display = "inline";
                }
                else {
                    document.getElementById("noJS").style.display = "none";
                    document.getElementById("noCookie").style.display = "inline";
                    document.getElementById("success").style.display = "none";
                }
                return true;
            }
            else {
                document.getElementById("noJS").style.display = "inline";
                document.getElementById("noCookie").style.display = "none";
                document.getElementById("success").style.display = "none";
                return false;
            }
            
        }


    </script>
</head>
<body onload="isScriptEnable();">
    <form id="form1" action=Cookie.html>
    <input type="hidden" name="cookieexists" value="false">
    <div id="success" style="display: none; color: green; display: none;">
        Your browser has met the requirements to use our service</div>
    <div id="noJS" style="color: red; display: none;">
        Please enable Javascript</div>
    <div id="noCookie" style="color: red; display: none;">
        Please enable Cookie</div>
    </form>
</body>
</html>

Open in new window


Regards,

Asif Ahmed Khan
0
khan_webguruCommented:
Hello Bro!

Another way to fix your problem please see the code below

 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    
    <script type="text/javascript" language="JavaScript">
           <!--
        function Get_Cookie(check_name) {
            // first we'll split this cookie up into name/value pairs
            // note: document.cookie only returns name=value, not the other components
            var a_all_cookies = document.cookie.split(';');
            var a_temp_cookie = '';
            var cookie_name = '';
            var cookie_value = '';
            var b_cookie_found = false; // set boolean t/f default f
            var i = '';

            for (i = 0; i < a_all_cookies.length; i++) {
                // now we'll split apart each name=value pair
                a_temp_cookie = a_all_cookies[i].split('=');


                // and trim left/right whitespace while we're at it
                cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

                // if the extracted name matches passed check_name
                if (cookie_name == check_name) {
                    b_cookie_found = true;
                    // we need to handle case where cookie has no value but exists (no = sign, that is):
                    if (a_temp_cookie.length > 1) {
                        cookie_value = unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g, ''));
                    }
                    // note that in cases where cookie is initialized but no value, null is returned
                    return cookie_value;
                    break;
                }
                a_temp_cookie = null;
                cookie_name = '';
            }
            if (!b_cookie_found) {
                return null;
            }
        }

        /*
        only the first 2 parameters are required, the cookie name, the cookie
        value. Cookie time is in milliseconds, so the below expires will make the 
        number you pass in the Set_Cookie function call the number of days the cookie
        lasts, if you want it to be hours or minutes, just get rid of 24 and 60.

        Generally you don't need to worry about domain, path or secure for most applications
        so unless you need that, leave those parameters blank in the function call.
        */
        function Set_Cookie(name, value, expires, path, domain, secure) {
            // set time, it's in milliseconds
            var today = new Date();
            today.setTime(today.getTime());
            // if the expires variable is set, make the correct expires time, the
            // current script below will set it for x number of days, to make it
            // for hours, delete * 24, for minutes, delete * 60 * 24
            if (expires) {
                expires = expires * 1000 * 60 * 60 * 24;
            }
            //alert( 'today ' + today.toGMTString() );// this is for testing purpose only
            var expires_date = new Date(today.getTime() + (expires));
            //alert('expires ' + expires_date.toGMTString());// this is for testing purposes only

            document.cookie = name + "=" + escape(value) +
		((expires) ? ";expires=" + expires_date.toGMTString() : "") + //expires.toGMTString()
		((path) ? ";path=" + path : "") +
		((domain) ? ";domain=" + domain : "") +
		((secure) ? ";secure" : "");
        }

        // this deletes the cookie when called
        function Delete_Cookie(name, path, domain) {
            if (Get_Cookie(name)) document.cookie = name + "=" +
			((path) ? ";path=" + path : "") +
			((domain) ? ";domain=" + domain : "") +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
        }


        Set_Cookie('test', 'none', '', '/', '', '');

        function cc() {
            
            
            if (Get_Cookie('test')) {
                
                
                cookie_set = true;

                Delete_Cookie('test', '/', '');
                return true;
            }
            // if the Get_Cookie test fails, cookies
            //are not enabled for this session.
            else {

                cookie_set = false;
                return false;
            }
        }

        
        
        // -->

        function isScriptEnable() {
            var browserName = navigator.appName;
            var browserVer = parseInt(navigator.appVersion);
            if ((browserName == "Netscape" && browserVer >= 3) || (browserName == "Microsoft Internet Explorer" && browserVer >= 4))
                version = "n3";
            else
                version = "n2";
            if (version == "n3") {
                if (cc()) {
                    document.getElementById("noJS").style.display = "none";
                    document.getElementById("noCookie").style.display = "none";
                    document.getElementById("success").style.display = "inline";
                }
                else {
                    document.getElementById("noJS").style.display = "none";
                    document.getElementById("noCookie").style.display = "inline";
                    document.getElementById("success").style.display = "none";
                }
                return true;
            }
            else {
                document.getElementById("noJS").style.display = "inline";
                document.getElementById("noCookie").style.display = "none";
                document.getElementById("success").style.display = "none";
                return false;
            }
            
        }


    </script>
</head>
<body onload="isScriptEnable();">
    <form id="form1" action="Cookie.html">
    
    <div id="success" style="display: none; color: green; display: none;">
        Your browser has met the requirements to use our service</div>
    <div id="noJS" style="color: red; display: none;">
        Please enable Javascript</div>
    <div id="noCookie" style="color: red; display: none;">
        Please enable Cookie</div>
    </form>
</body>
</html>

Open in new window



Regards,

Asif Ahmed Khan
0
khan_webguruCommented:
Hello Bro!

LIVE DEMO you can test here!


http://www.tec-i.com/gEwCart/HowToEnableJavascriptAndCookies.htm

source of this site

view-source:http://www.tec-i.com/gEwCart/HowToEnableJavascriptAndCookies.htm


take the code from source if you like to use this

Regards,

Asif Ahmed Khan
0
Computer GuyAuthor Commented:
Hi gurvinder372,

Still the same result.
0
Gurvinder Pal SinghCommented:
is it still showing 'Cookies are disabled' when javascript is disabled?
0
Computer GuyAuthor Commented:
yes
0
khan_webguruCommented:
tested mine???
0
Gurvinder Pal SinghCommented:
So, it should be showing both. How can it be possible?
how did you tested it?

try this now
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<script src="jquery-1.4.2.min.js"></script>
		<script>
			$(document).ready(function(){
				$("#noJS").html("Cookies are disabled");
				if ( isCookieEnabled( ) )
				{
					$("#noJS").hide();
					$("#success").show();
				}
			});
			function isCookieEnabled( )
			{
				var cookieEnabled = (navigator.cookieEnabled)? true : false;

				if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled)
				{ 
					document.cookie = "testcookie";
					cookieEnabled = ( document.cookie.indexOf( "testcookie" ) != -1 ) ? true : false;
				}
				return cookieEnabled;
			}
		</script>
	</HEAD>

	<BODY>
		<div id="success" style="display:none;color:green">Your browser has met the requirements to use our service</div>
		<div id="noJS" style="color:red">Javascript is disabled</div>
	</BODY>
</HTML>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Computer GuyAuthor Commented:


For testing, I had both js and cookies enabled. Got the success message.

Then disabled js and left cookies enabled. Got the js and cookies disabled message.
0
Gurvinder Pal SinghCommented:
did you again got the same error with my latest code that i shared?
0
khan_webguruCommented:
Hello Bro!


FINAL TRY FROM MY SIDE THAT SHOULD WORK PLEASE FIND THE CODE BELOW

 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<script src="jquery-1.4.2.min.js"></script>
		<script>
		    $(document).ready(function () {
		        $("#noJS").html("Cookies are disabled");
		        if (isScriptEnable()) {
		            if (isCookieEnabled()) {
		                $("#noJS").hide();
		                $("#noCookie").hide();
		                $("#success").show();
		            }
		            else {
		                $("#noJS").hide();
		                $("#noCookie").show();
		                $("#success").hide();
		            }

		        }
		        else {
		            $("#noJS").show();
		            $("#noCookie").hide();
		            $("#success").hide();

		        }
		    });

		    function isCookieEnabled() {
		        var cookieEnabled = (navigator.cookieEnabled) ? true : false;

		        if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled) {
		            document.cookie = "testcookie";
		            cookieEnabled = (document.cookie.indexOf("testcookie") != -1) ? true : false;
		        }
		        return cookieEnabled;
		    }

		    function isScriptEnable() {
		        var browserName = navigator.appName;
		        var browserVer = parseInt(navigator.appVersion);
		        if ((browserName == "Netscape" && browserVer >= 3) || (browserName == "Microsoft Internet Explorer" && browserVer >= 4))
		            version = "n3";
		        else
		            version = "n2";
		        if (version == "n3") {
		            
		            return true;
		        }
		        else {		            
		            return false;
		        }

		    }

		</script>
	</HEAD>

	<BODY>
		<div id="success" style="display:none;color:green">Your browser has met the requirements to use our service</div>
		<div id="noJS" style="color:red">Javascript is disabled</div>
        <div id="noCookie" style="color:red">Cookie is disabled</div>
	</BODY>
</HTML>

Open in new window


hope this will solve your problem. other wise its very strange. Let me know in any case.

Regards,

Asif Ahmed Khan
0
khan_webguruCommented:
Hello Bro!

Don't shock why I used classic JAVASCRIPT instead of JQuery to script enabling check because for JQuery you have to include Jquery.js if it will block then how you can call its methods so first check about script with normal javascript then check COOKIE with JQuery.

Regards,

Asif Ahmed Khan
0
khan_webguruCommented:
Hello audiotech520,

See Logically speaking,

1

By Default I am assuming in the Following code that JAVASCRIPT is disabled for the page.

2

So what I did I set display:none for cookie and success message.

3

Then on JQuery onReady I hide "DISABLED JAVASCRIPT" msg because that will fire only if JAVASCRIPT enable for the page.

4

Then I checked FOR COOKIE

5

AND SET MESSAGE IF COOKIE ENABLE AND VICE VERSA.

 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<script src="jquery-1.4.2.min.js"></script>
		<script>
		    $(document).ready(function () {
		        $("#noJS").hide();
		        if (isCookieEnabled()) {
		            
		                $("#noJS").hide();
		                $("#noCookie").hide();
		                $("#success").show();		        

		        }
		        else
                {
                        $("#noJS").hide();
		                $("#noCookie").show();
		                $("#success").hide();		        
                }

		    function isCookieEnabled() {
		        var cookieEnabled = (navigator.cookieEnabled) ? true : false;

		        if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled) {
		            document.cookie = "testcookie";
		            cookieEnabled = (document.cookie.indexOf("testcookie") != -1) ? true : false;
		        }
		        return cookieEnabled;
		    }

		    

		</script>
	</HEAD>

	<BODY>
		<div id="success" style="display:none;color:green">Your browser has met the requirements to use our service</div>
		<div id="noJS" style="color:red">Javascript is disabled</div>
        <div id="noCookie" style="display:none;">Cookie is disabled</div>
	</BODY>
</HTML>

Open in new window



WHAT YOU THINK ????

NOW TRY THIS HOPEFULLY THAT WILL SOLVE THE PROBLEM.


REGARDS,

ASIF AHMED KHAN
0
Computer GuyAuthor Commented:
Hi Gruvinder,

I used the code in post: ID: 35231200, which was your last post.


Is it true that if I include the JQuery script, that someone can block it?
0
khan_webguruCommented:
I tried to explain that if Javascript will be block then javascript file can't be load and jQuery ready event can't be fire
0
Gurvinder Pal SinghCommented:
<<Is it true that if I include the JQuery script, that someone can block it?>>
Jquery is nothing but javascript library. So the logic is that if the jquery event is getting fired then it means javascript is not disabled.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.