Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts

    can i detect if JS is disabled?

    i realise that reading the "disabled/enabled" value from the users settings would be a security risk... so heres an idea

    can a script be used to send a JS command (or something) to a user, and if the command isnt rejected then that means JS is enabled?
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #2
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <NOSCRIPT>
     <P>Access the <A href="http://someplace.com/data">data.</A>
    </NOSCRIPT>
    http://www.w3.org/TR/REC-html40/inte....html#h-18.3.1

  • #3
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    i suppose that works
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    or, if you need it for another event handler inside the page

    <a href="nonjspage.html" onclick="location.href='jspage.html';return false">GO</a>
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    actually i meant something more involved than that.. come to think of it.

    i wanted to know if i could do something like this

    mad suedo code:
    Code:
    <script>
    ... try to activate a simple js function.
    
    function jsYesNo ()
    {
      var test = 0;
      test = test + 1;
      
       if (test = 1) 
        { return true; }
       else 
        { return false; }
    }
    
    
    <body>
    
    <div if jsYesNo="false" (show this div)>
    Javascript is needed for this page blahblah
    </div>
    i figured i could use something non-js to evaluate whether a JS function worked. if it didnt i could program the reaction accordingly
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #6
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anything in noscript tags is only shown if no script is enabled. And btw logic dictate that you cannot use something thats disabled to test if its disabled, simply for the simple reason that it wouldn't truely be disabled then.

    <noscript>
    <div if jsYesNo="false" (show this div)>
    Javascript is needed for this page blahblah
    </div>
    </noscript>

  • #7
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    does noscript only apply to javascript, or all types of scripting?
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #8
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    For IE, it also covers client-side VBScript.

    http://www.w3schools.com/tags/tag_noscript.asp
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #9
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    in IE you can't solely disabled JS but leave VBS enabled. this is because both scripting techs are subsumed under ActiveScripting. in order to disable one or the other, you disable ActiveScripting and therefore both.

    this presumably also pertains to any other scripting that may be possible clientside such as Ruby, PerlScript, etc (tho I've never known it possible to script the client with these, so i ... er ... guess not then LOL).
    *keep it simple (TM)

  • #10
    Regular Coder
    Join Date
    Jun 2004
    Posts
    565
    Thanks
    0
    Thanked 18 Times in 18 Posts
    If you want to show/hide some content of a page if javascript is disabled, let js append/remove the content or have the element be hidden/shown by default and change it with js, e.g.:

    Code:
    <script type='text/javascript'>
      function show_content() {
        document.getElementById('no_js').style.display = 'none';
      }
      window.onload = show_content;
    </script>
    
    ...
    
    <div id='no_js'>javascript needed.</div>
    dumpfi

  • #11
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    sounds good, however i would need it to appear IF javascript was disabled

    which puts us back at the noscript option

    does noscript take up space on the page??

    i.e the difference between visibility.hide and display: none being one still keeps it in the page spacewise and one doesnt...
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #12
    Regular Coder
    Join Date
    Jun 2004
    Posts
    565
    Thanks
    0
    Thanked 18 Times in 18 Posts
    Quote Originally Posted by canadianjameson
    sounds good, however i would need it to appear IF javascript was disabled

    which puts us back at the noscript option
    I think you haven't understood what i said. If you have an element in your page and use js to hide it, the element will still be visible if js is disabled.

    dumpfi

  • #13
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by dumpfi
    I think you haven't understood what i said. If you have an element in your page and use js to hide it, the element will still be visible if js is disabled.

    dumpfi
    heh, i think you have misunderstood my intentions kind sir.

    i'm not using JS to hide anything, i wanted to show a message to users whose JS was disabled, but not to people whose wasnt. i was look for a way to test whether a user had it disabled, and based on that being true, show something. however i've realised this is logically impossible to do without an IF statement... putting us back to square one
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #14
    Regular Coder
    Join Date
    Sep 2004
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Isn't that exactly what the <NOSCRIPT> tag is for?

  • #15
    Regular Coder
    Join Date
    Jun 2004
    Posts
    565
    Thanks
    0
    Thanked 18 Times in 18 Posts
    Quote Originally Posted by canadianjameson
    heh, i think you have misunderstood my intentions kind sir.

    i'm not using JS to hide anything, i wanted to show a message to users whose JS was disabled, but not to people whose wasnt.
    I don't think there would be a difference for normal users if the message was hidden or nonexistent if they had js enabled. In both cases the user doesn't notice it.

    But go with the noscript-tag if you like it.

    dumpfi


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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