SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Dec 2006
    Location
    Gothenburg, Sweden
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Find out if the user's browser supports JavaScript and AJAX

    Hello all,

    I'm developing a site that will use technologies like JavaScript and AJAX. I want the site to be functional for people that has older browsers or JavaScript turned off so for this I need to find out if the user's browser is supporting JavaScript and AJAX.

    How can I check this in an easy and simple way? I.e the user enters my website with JavaScript turned off at the moment. And then he turns it on and reloads the page. I would like to catch that he has turned JavaScript on. The same goes with AJAX (although there is no off/on setting for AJAX).

  2. #2
    SitePoint Zealot
    Join Date
    Dec 2006
    Location
    Gothenburg, Sweden
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone? This must be quite a common problem.

  3. #3
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You generally don't detect it. You should rather write your code to work without javascript turned on, and then let the javascript be an extension to the existing code. This is also known as unobtrusive javascript.

  4. #4
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use javascript to add functionality to a website.

    If javascript is not supported or enabled, it is irrelevant to the user.

  5. #5
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,445
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)

    testing for js

    You may not now consider it "easy and simple", but writing unobtrusive code is the correct way.
    If javascript isn't enabled, the script doesn't run (obviously), but users still get a workable page.
    If javascript is enabled, test for the existence of whatever functions you want to use before you attempt to use them. This way users with older versions of javascript without newer functions will still get a workable page.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •