SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how do i know if a browser support Javascript

    hello,
    how do i know if a browser supports javascript or not ?

    I implemented some javascript on my site, but noticed that some browsers do not support our scripts.

    i am using IE 5.0 now on another system, and it doesnt seem to work

    Afrika

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    HTML Code:
    <script type="text/javascript">
    alert('Javascript works!');
    </script>
    <noscript>
    <p>Javascript doesn't work.</p>
    </noscript>

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to test for support of a particular function or property, you can do it with the typeof() function:
    Code:
    <script type="text/javascript">
        if (typeof(document.getElementById) == "function") {
            alert("getElementById() is supported.");
        }
    
        if (typeof(document.rebootComputer) == "undefined") {
            alert("rebootComputer() is not supported.");
        }
    </script>
    Birnam wood is come to Dunsinane

  4. #4
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Suggested Design Stages...

    (1) Design your page only as HTML. No CSS and no Javascript. Test it in different browsers. This is your basic structure upon which you will build.

    (2) Add CSS for presentation and layout. Test it in different browsers. This is the "downgrade" version of your page. You should assume that this is what many (if not all) users will get.

    (3) Now add "unobtrusive" behavior with Javascript. Test it in different browsers. Anything added at this stage should only have an effect on the page if Javascript is enabled and all required objects are supported.

  5. #5
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for all your input, however is there anyway i could know on the server end ? so as to alert the user that he cannot use my site ??

  6. #6
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unless there is some reason you need to know on the server side, you can use the method in vgarcia's post to display a message to the user.

  7. #7
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use the <noscript> element as Vinnie did in his example.

    (Having a site require JavaScript is not very friendly, though. )
    Birnam wood is come to Dunsinane

  8. #8
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, thanks for your advice


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
  •