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 24
  1. #1
    mbl
    mbl is offline
    New Coder
    Join Date
    Sep 2004
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can JavaScript function detect J.S. disabled?

    Dear friends,

    On realizing that a minority of users (fortunately) may have JavaScript disabled at their browser, have used the <noscript> tags as is conventional.

    However, was wondering if it is possible for a JavaScript function to contain code that when the function is called, an alert box would show stating something like "Your browser is currently supressing JavaScript functioning"?

    Probably not possible, but then, how to know if not by asking?

    Or is there other alternative to the <noscript> aproach?

    Also, since JavaScripts is so useful and therefore popular, perhaps some message like that ought to be a property of the various browsers. Unless a script language is inherent in all of them, would say, and would like to know if there is such a concept going on somewhere.

    Thanks.

    -mbl-

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,734
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    If Javascipt is disabled it is er, well, disabled, and cannot detect anything.

    The only solution is to have another page to which users without scripting enabled can be re-directed via the <noscript> tag.

  • #3
    Regular Coder
    Join Date
    Oct 2004
    Posts
    168
    Thanks
    0
    Thanked 5 Times in 5 Posts
    You need to continue to put an appropriate message / link / instructions et al, in the <noscript> section. There is nothing wrong with using <noscript> on a page prior to JavaScript execution to act as an early warning.
    This may be seen as a disadvantage of the client-side approach but then JavaScript should never be mission critical for a site's functionality.
    One possibility to consider is to create a cookie using JavaScript. If the cookie is not created then the browser may not be capable of JavaScript and a server-side language could be used to warn the visitor to that effect.
    Of course, there are other reasons why the cookie may not be created.

    HTH
    Last edited by Puffin the Erb; 11-07-2004 at 08:42 PM.

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Creating a cookie to detect javascript is a poor choice...
    I have javascript enabled but cookies disabled...

    Creating a var and checking for the variable would be sufficient....

    But that is an interesting concept: using script to alert a user that they have script disabled

    .....Willy

  • #5
    mbl
    mbl is offline
    New Coder
    Join Date
    Sep 2004
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Willy Duitt
    Creating a cookie to detect javascript is a poor choice...
    I have javascript enabled but cookies disabled...

    Creating a var and checking for the variable would be sufficient....

    But that is an interesting concept: using script to alert a user that they have script disabled

    .....Willy
    Yes it is a logical thought that kind of brings its own answer, but also bring this one: Since it is the Browser which turns JS off, then, would say it ought to be the browser which notifies the user of a JavaScript attempt, somewhat like is done for other security warnings when they are turned off.

    Just found through google a while ago that 99.5% or so of users have JavaScript ON and since what am doing is not critical, will stay simple with a minimum of <noscript>.

    Thanks for the replies, every one.

    -mbl-

  • #6
    Regular Coder
    Join Date
    Oct 2004
    Posts
    168
    Thanks
    0
    Thanked 5 Times in 5 Posts
    Hi there!
    Bear in mind the stat is related to browsers that are capable of JavaScript.
    Text-only browsers, for example, don't support it.

    ....... Willy, I don't understand your idea of creating a var and then checking for it.
    What would you check for it with?
    Sorry if I'm losing the plot.

  • #7
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mbl
    Yes it is a logical thought that kind of brings its own answer, but also bring this one: Since it is the Browser which turns JS off, then, would say it ought to be the browser which notifies the user of a JavaScript attempt, somewhat like is done for other security warnings when they are turned off.
    If you disable active scripting you will find that those security alerts (such as those for ActiveX disabled) will disappear also since they are the result of VB script.... No script, no alert....

    Puffin the Erb;

    It depends upon your need and what you wish to do with the information if javascript is enabled or not... Generally, you would check if javascript is enabled and if so redirect to a javascript dependent page but you could also set a variable and send this value serverside to be processed depending upon your need...

    .....Willy

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mbl
    Yes it is a logical thought that kind of brings its own answer, but also bring this one: Since it is the Browser which turns JS off, then, would say it ought to be the browser which notifies the user of a JavaScript attempt, somewhat like is done for other security warnings when they are turned off.
    Well in the case of IE it can - you can set active scripting to "prompt". I have "cross frame scripting" in IE set to prompt so that I'm aware when a site is trying to do it - that's a security risk which I normally refuse, but my online banking doesn't work without.
    Just found through google a while ago that 99.5% or so of users have JavaScript ON and since what am doing is not critical, will stay simple with a minimum of <noscript>.
    I wouldn't put faith in that. Estimates I've read put it anywhere between 0% and 20% - I would go with 5-10% as a more realistic estimate (which includes robots themselves)

    But anyway ... the script + noscript paradigm is not reliable, because it doesn't cater for primitive JS browsers like Netscape 3 or WebTV - they can't handle complex scripting, but they do support javascript, so they won't parse the noscript either.

    The all-round best thing to do is do all your scripting in the DOM, binding methods to HTML elements which are there anyway.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #9
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just an FYI...

    I have done alot of scripting for WebTv, particularly the older builds which were IE4 compatable (they just released a newer build based upon Windows CE and IE6 compatable) and they do support the <noscript> tags.... However, they (WebTv users) have no control and can not disable Active Scripting... Additionally, a problem arises due to WebTv taking a users requested page and prior to rendering the page for the end user they parse it on their server in an attempt to parse out any malicious code (ActiveX Controls, Javascript, VB Script, ect)... It is during this parsing that they convert script to their own forms of scripting known as Telly/Jelly script (much like vBulletin parses out HTML tags)... and often the resultant page does not convert completely leaving a run time error which kills any script on the page and effectively makes a script dependent page unusable.... In WebTv terms, this is affectionetely known as "The Javascript Bug" and the only known fix is to continue to reload the page until the script is properly converted to its Telly/Jelly script counterpart....

    Of course this parsing/converting is much more entailed but the above is the simplist way I know of describing WebTv's behavior... But it should be noted that any malformed script which is throwing errors prior to converting to Telly/Jelly script will never have a chance to be problerly converted and the page will not have a chance to ever render properly despite how many times a WebTv user reloads the page and it is not unheard of for them to reload a page 15-20 times...

    .....Willy

  • #10
    Regular Coder
    Join Date
    Jan 2004
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The best way to determine this is on the server end with a product like Browser Hawk. I am using their product and redirecting users accordingly since my site requires javascript and popup windows.

  • #11
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Willy Duitt
    I have done alot of scripting for WebTv, particularly the older builds which were IE4 compatable (they just released a newer build based upon Windows CE and IE6 compatable) and they do support the <noscript> tags....
    My point exactly - they do support <noscript> - but if you run a complex script that it can't handle, it won't parse the <noscript>, because it does support the script.

    But if you do all your scripting by sniffing for uplevel support and binding behaviors in the DOM to elements which are still there in plain HTML, you avoid these kinds of problems.
    Quote Originally Posted by FastCougar
    The best way to determine this is on the server end with a product like Browser Hawk. I am using their product and redirecting users accordingly since my site requires javascript and popup windows.
    I wouldn't wanna rely on that ... unless they know something we don't, server-side browser detection is fundamentally unreliable.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #12
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by brothercake
    My point exactly - they do support <noscript> - but if you run a complex script that it can't handle, it won't parse the <noscript>, because it does support the script.
    Please accept my apologies for any confusion I may have caused....

    My memory failed me and I thought the <noscript> tag was used when the WebTv box suffered from the infamous "Javascript Bug" but I just checked my files and realized that a combination of <noframes> (WebTv does not support frames) and using script to document.write comment tags to the page was used instead....

    Code:
    <noframes><script>
    if(navigator.appCodeName=='bowser'){document.write('<'+'!'+'-'+'-') }</script>
    WebTv Javascript Bug!  Press cmd+r for 5 seconds! WebTv Javascript Bug!! --></noframes>
    .....Willy

  • #13
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Jeeze what a tedious bug. Well afaik the latest version is the MSN-branded 2.8 - does it still have that same problem?
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #14
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I believe the old WebTv boxes using the IE4 compatable browser are up to build 2.9 now.... However, they just released a new box, totally different from the old box... It's still in Beta Testing but they pushed release to get it into the stores for the Christmas Holidays... It's now called MSNTV2 and a link to their new site can be found here....

    I'm currently involved with a group whom is testing TNB and trying to figure out what part of the DOM is actually supported... However, things are changing erveryday and there still is a problem with popups and frames....

    Additionally, several other Set Top Boxes have also recently been released (I would have to look for those links) but I am not familar with those other than they too are using Windows CE OS and a stripped down version of IE6....

    Anyways, evidently some major players are still banking on networking Set Top Boxes with PC's to be used as media centers so it is something to keep an eye on...

    .....Willy

    BTW: In answer to your question... The old 2.8, 2.9 does still have the "Javascript Bug" and I'm pretty sure the new box does also but is not as prevelant and locks the box up and the only escape is to power off and reboot...
    Last edited by Willy Duitt; 11-09-2004 at 03:19 AM.

  • #15
    Regular Coder
    Join Date
    Jan 2004
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by brothercake
    I wouldn't wanna rely on that ... unless they know something we don't, server-side browser detection is fundamentally unreliable.
    I'd care to say that they know A LOT more than you and many others ... they have been doing this since 1994 and are used by countless fortune 100 companies for their internet and intranet sites. I have used this product for the past year with absolutely no problems what-so-ever for a client portal.


  •  
    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
    •