Results 1 to 8 of 8

Thread: check whether javascript is enabled!

  1. #1
    Join Date
    Jul 2007
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Post check whether javascript is enabled!

    I am trying to check browsers whose javascript settings are disabled or enabled. If enabled, i'll let them surf on site but if not, there should be a message which shows;

    Pls Enable your browsers Javascript setting and refresh the page.

    How can i achieve this?

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    My response to this is to say 'no' and go elsewhere. If I'm feeling charitable, I'll write you a stern email explaining that your site is inaccessible to a significant minority of people, some of whom have disabled Javascript by choice (and are almost certainly not going to enable it just for you) and the rest of whom are incapable of using Javascript.

    The very asking of this question implies a fundamental misunderstanding of the nature of the Web. Javascript is an enhancement — it can be used to do great things, but these are enhancements of the main page, for purposes of flashiness or convenience, and the page should be quite usable without it.

    The correct Web design process is called 'progressive enhancement', and it involves building your site in a series of layers. First, you have the bare information. This is just text. Then, enhance it by adding HTML to show what's what — you shouldn't be worried about how it looks at this stage; focus on defining the different parts of your document semantically. The next layer to go on is images. All of these should have 'alt' attributes if they convey any extra information, for the people who can't access this layer, such as those on screenreaders, small displays, or text-only browsers. Following this, you should add CSS to your pages — this is where you start worrying about making it stylish and emphasising the important parts of your information using things like size, weight, font, and colour, as well as laying out the page the way you want it. Some editing of your markup might be necessary, to add classes or wrap things in container elements, but the page should still work without the style. The very final layer is scripting, where you add asynchronous requests, loading bars, bouncy menus, spinning buttons, and things that go 'pop!'. Crucially, for each layer of design, all the layers up until that one should still be accessible even if that layer is removed, since each layer has an associated subsection of your viewers who will be unable to access it, and who will be quite annoyed if they're denied access to the information that your page is designed to convey, and which is, after all, the whole point of the page.
    Last edited by Twey; 10-01-2008 at 04:56 PM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jul 2007
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hi Twey,

    Personally I think you are so professional on your work that you worry about that so much. You don't suggest a piece of code to me but i suggest you something;

    - some websites don't function on Mozilla it is forbidden by javascript
    - some content cannot copied it is done by javascript
    - some ................
    - some ................
    - some ................
    - some ................

    that goes like this. If i am the author, text writer, designer and some parts coder. I HAVE THE RIGHT TO DIRECT IT. If i cant direct by saying the rules of web 'progressive enhancement' i am not the DIRECTOR of my web site. So are you?

    I have respect your sentences, but don't behave me as i am a stingy. If i had been a stingy person I wouldn't have created a website which is intended for Education. In addtion it is fully free. In addition i have no ads which will fake visitors.

    It is not an adult site, i even don't know these kind of trick.

    Thanks for your helps, i am really grateful

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    - some websites don't function on Mozilla it is forbidden by javascript
    'Forbidden'?
    - some content cannot copied it is done by javascript
    Not at all true — I suggest you search for some other threads on this subject. We've plenty, and the conclusion is clear: it isn't possible. Anything you put on the Web can be copied, saved, and viewed, since by the time it's viewed by the user, it's already out of your hands. Copyright law exists to protect you here, if it really causes you damages.
    that goes like this. If i am the author, text writer, designer and some parts coder. I HAVE THE RIGHT TO DIRECT IT. If i cant direct by saying the rules of web 'progressive enhancement' i am not the DIRECTOR of my web site. So are you?
    Certainly. If you particularly want to unnecessarily drive away a portion of your visitors and have your site stand out as an example of the worst the Web has to offer, go right ahead. They're guidelines, not rules, but guidelines that exist for a damn good reason.
    If i had been a stingy person I wouldn't have created a website which is intended for Education. In addtion it is fully free. In addition i have no ads which will fake visitors.
    I assure you that I don't think you stingy. Money hadn't even entered into the equation. Rather, I think you a newcomer to web design who has most likely been exposed to bad information, as so much of it is on this topic, and doesn't fully understand the issues surrounding the subject. You're far from alone, and helping such people by spreading better information is probably my sole unselfish reason for attending this forum.

    Education should be available to all, not just those with a system and browser set up as you dictate. While I commend your goals, I stand by what I have said above as a better way of achieving them.
    It is not an adult site, i even don't know these kind of trick.
    On the assumption that you mean strategies like progressive enhancement: And now you do! Education at work
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    May 2007
    Location
    USA
    Posts
    373
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default

    Setting aside the opinions of the issue, isn't the noscript html tag what you want?
    Trinithis

  6. The Following User Says Thank You to Trinithis For This Useful Post:

    nolikewise (10-01-2008)

  7. #6
    Join Date
    Jul 2007
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Smile

    Quote Originally Posted by Trinithis View Post
    Setting aside the opinions of the issue, isn't the noscript html tag what you want?
    Trinithis, all i want is this: I have a website and it uses php, js, swf and normally html. To make it function properly I would like to make it check if users browser javascript is enabled or disabled when it starts to laod.

    If disabled show a message
    If enabled show website

    no more, no tricks, no fakes, no hacks, no, no, no, it is quite simple.

    Thank you for your concern. I am watching this topic.

  8. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,979
    Thanks
    43
    Thanked 3,195 Times in 3,157 Posts
    Blog Entries
    12

    Default

    I agree with what Twey has said, at least as I understand it, and don't think he was being mean about it, rather quite generous in his explanation. And, though it may appear to be an opinion, and may be to an extent, it is basically just the facts of the matter. To the extent that it is an opinion, it is one supported by those facts. Trinithis' idea is the standard approach if one still insists upon doing such a thing:

    HTML Code:
    <noscript><p>Your message to non-javascript enabled browsers here</p></noscript>
    This can be 'enhanced' (in reality degraded) by a combination of javascript and css, such that no content other than the non-script content be rendered for non-javascript browsers. Remember, as Twey says, many of these users cannot turn on javascript. Something I think he left out is that some of them wouldn't benefit from having javascript, even if they could. These include blind users with screen readers, probably others.

    Now, if you still want to go all the way with this highly questionable concept, you can organize your body section like so:

    HTML Code:
    <body>
    <div><noscript><p>Your message to non-javascript enabled browsers here</p></noscript></div>
    <div id="content">
    The actual content of your page goes here
    </div>
    </body>
    Use this style followed by the script shown, put both in or (preferably) link both to the head section of your page, the order is important:

    Code:
    <style type="text/css">
    #content {
    display: none;
    }
    </style>
    <script type="text/javascript">
    document.write('<style type="text/css">#content {display: block;}<\/style>');
    </script>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Still works if one disables or lacks both style and script, of course.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •