• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 156
  • Last Modified:

JavaScript Detection

Hi Experts,

Is there a way that I can detect if a browser has JavaScript enabled, the JavaScript version (if there is such a property), and if pop-ups are enabled?

Thank you
0
APD Toronto
Asked:
APD Toronto
4 Solutions
 
Dave BaldwinFixer of ProblemsCommented:
No, not really.  You can use AJAX to detect that it IS enabled but not that it is disabled.  Pretty much the same with popups.  You have to use AJAX in the popup to tell you that it works.  Without AJAX, the server never knows if those things are available and you can't use javascript to detect itself if it is disabled.
0
 
RobOwner (Aidellio)Commented:
The javascript version is tied with the version of the browser.  You can get this information using the get-browser function: http://php.net/manual/en/function.get-browser.php

you can also display to the user what to do if their javascript is disabled by using the noscript tags:  http://www.w3schools.com/tags/tag_noscript.asp

To detect if JavaScript is disabled you would have to do some double handling such as having the browser use javascript to perform an AJAX call to start a session and then that page would redirect to detect if the session was created or not, indicating whether JS is enabled.
We've discussed this at length before: http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_28499742.html
My comments in that question that it is NOT possible are specific to a page and not having to refresh or redirect.
0
 
Dave BaldwinFixer of ProblemsCommented:
Here http://www.dibsplace.com/jscr.html is a page I use for some javascript into.  Copy the code if you want, I did.
0
 
Rainer JeschorCommented:
Hi,

to detect if JavaScript is enabled/disabled there are two main techniques:
1. Use the <noscript> tag
This one should only be displayed/executed when JavaScript is disabled.

2. Set a cookie with JavaScript and create a new request to the server. Then you can check if the cookie exists/contains a value on the server side

To detect if popups are blocked you might try this JavaScript code:
var myWindow=window.open('http://justanotherurl',"","width=1,heigh=1"); 
if (myWindow== null || typeof(myWindow)=='undefined') { 
  alert('Popups are disabled'); 
}

Open in new window


Please be aware that the last time I did use this check has been a couple of years ago and I do not know how the latest browsers and add-ons react on this.

To detect the JavaScript version you can try something like this:
http://jsfiddle.net/Ac6CT/

HTH
Rainer
0
 
Ray PaseurCommented:
Here is my take on it.  Maybe this can work for you, too.  Browsers do not reveal much information to the server.
http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/A_17334-Detecting-Client-Browser-Settings-for-Cookies-and-JavaScript.html
0
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.

Join & Write a Comment

Featured Post

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now