www.webdeveloper.com
Results 1 to 10 of 10

Thread: Disabling Javascript on page

  1. #1
    Join Date
    Dec 2011
    Posts
    20

    Disabling Javascript on page

    Emm I started implementing javascript to my web site, but when I came in mind that user agent(browser) can disable running javascripts I was confused Whats the point coding with javascript if site visitor can disable it ...?
    I just code few good functions that protects my website, but when I remembered that I can disable javascript via browser it just killed me...
    Maybe you know any other languages similar to javascript and that user cannot disable it?
    Last edited by xbatista; 11-10-2012 at 04:14 PM.

  2. #2
    Join Date
    May 2004
    Location
    Manhattan NY
    Posts
    6,028
    There is no other option. Today's web pages have so much scripting that if a user disabled JavaScript in most cases the site will become unusable for them.

  3. #3
    Join Date
    Mar 2011
    Posts
    1,145
    The good news is that the percentage of users running with JavaScript disabled is in the single digits. But best practice is to always code your pages so that they degrade gracefully for users running with JavaScript disabled. This generally means including hard-coded links for navigation (<noscript> sections can help here), and display layouts that default to a usable state. The degree to which you need to accommodate those users will vary widely depending on the audience for the site. A technical site, for example, probably doesn't need to do much more than include a warning in a <noscript> section that the site requires JavaScript to function properly. But a general audience site should insure that all major functions (especially navigation links) work without requiring JavaScript.
    Rick Trethewey
    Rainbo Design

  4. #4
    Join Date
    Dec 2011
    Posts
    20

    Question

    Code:
    <script>
    // For sure it must be javascript functions
    if ( !isset(cookie['javascript'])
    set_cookie('javascript', blablabla, 1second)
    else
    delete_cookie('javascript')
    again_set_cookie('javascript', blablabla, 1second)
    </script>
    // Check with PHP now
    if ( !isset($COOKIE['javascript']) )
           echo "Sorry please enable javascript";
           exit;
    That will be correct for checking if javascript enabled/disabled?

    P.S. It is possible somehow for user to add a cookie manually?

  5. #5
    Join Date
    May 2004
    Location
    Manhattan NY
    Posts
    6,028
    Not necessary. Just include the no script tags as the previous poster suggested and put whatever message you like inside them.

  6. #6
    Join Date
    Dec 2011
    Posts
    20
    I'd better disallow user browsing on my website, I need javascript for some check/protect capabilities

  7. #7
    Join Date
    Aug 2008
    Location
    Sweden
    Posts
    227
    You shouldn't rely on validating user input with JavaScript. Validation should happen on the server, because users can always manipulate and execute scripts in their own clients, but they can't control what happens on the server.

    Edit: I can also add that users can add/edit cookies. They can also allow JavaScript but block cookies. A server or webpage has no real control over what happens in any client, simply said.
    Last edited by ReFreezed; 11-11-2012 at 09:27 AM.

  8. #8
    Join Date
    Dec 2011
    Posts
    20
    Okay thank you for your answers, I think , I should code carefully with javascript, because in any time user can disable it :/

  9. #9
    Join Date
    Aug 2008
    Location
    Sweden
    Posts
    227
    You can think of JavaScript as something used to enhance the experience for users on a website, rather than for adding restrictions for users. :)

  10. #10
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    you can disable CSS and images, but most sites still use those technologies.
    you can use javascript to redirect the user into an upgraded javascript-enabled version of your site.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles