Strange behaviour with Javascript detection

Posted on 2010-01-07
Last Modified: 2013-11-18
I have a simple HTML page which has some Javascript on to display the browser type on screen. At the end of the page i have <noscript> tags incase they dont have Javascript enabled.
Everytime i test this in Firefox and IE (by disabling/enabling Javascript) it works fine for me, however some of our users experience the following problems:
The javascript to display their browser type shows up perfectly fine then at the end of the page the <noscript> tags also executes and shows a message saying sorry but you hava no Javascript enabled. HOW can this possibly be that Javascript executes and then it says javascript is not available!?? In most cases users have had ZoneAlarm or some firewall but what would a firewall do to interfer with this?
Anyone got a clue whats going on?

Question by:guswebb
    LVL 7

    Expert Comment

    LVL 40

    Expert Comment

    you should avoid using noscript

    There are some recommended noscript settings, please see
    LVL 9

    Author Comment

    So are you saying that the best way to determine whether they have JS or not is to execute a function to see whether or not it works, if it works then JS is enabled otherwise if it doesnt work then its disabled?
    LVL 40

    Expert Comment

    LVL 40

    Expert Comment

    and there is a simple way

    you can also save a cookie, so if the javascript is enabled, cookie will be saved, else it wont be.
    LVL 9

    Accepted Solution

    I prefer not to use Cookies, does this look like the best approach to resolve the issue then:

    // HTML
    <div id="mainContent"> page content including JS output here</div>
    <div id="noScript">JS IS DISABLED</div>

    document.getElementById("mainContent").style.display= "inline";
    document.getElementById("noScript").style.display= "none";

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (, typical array handling might look like this: (CODE) B…
    Before we dive into the marketing strategies involved with creating an effective homepage, it’s crucial that EE members know what a homepage is. In essence, a homepage is the introductory, or default page, of a website that typically highlights the …
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now