SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2006
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JavaScript Enabled / Not ?

    I want to check if the Javascript is enabled or not ? and it it is not enabled i want the page to stop loading ,how can i do this ?

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It's a good idea to not do this.

    Why do you want to stop the page loading if javascript isn't enabled? If you do things properly, you should be able to display a page that at the very least displays the information you want to give to the user. Then if javascript is enabled, you add the javascript functionality to the existing HTML.

    You can't check if javascript is enabled without javascript. How can you know what an apple tastes like without tasting the apple? If it's enabled, you run your javascript. If it isn't, then your javascript doesn't run.

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2007
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Raffles View Post
    It's a good idea to not do this.

    Why do you want to stop the page loading if javascript isn't enabled? If you do things properly, you should be able to display a page that at the very least displays the information you want to give to the user. Then if javascript is enabled, you add the javascript functionality to the existing HTML.

    You can't check if javascript is enabled without javascript. How can you know what an apple tastes like without tasting the apple? If it's enabled, you run your javascript. If it isn't, then your javascript doesn't run.
    Yea the only way to test for Javascript would be to load your whole page via Javascript, therefore if it isn't enabled nothing happens.

  4. #4
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    noscript>
    <meta http-equiv="refresh" content="0;URL=non-javascript-version.html">
    </noscript>

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by stereofrog View Post
    Code:
    noscript>
    <meta http-equiv="refresh" content="0;URL=non-javascript-version.html">
    </noscript>
    Nope. Meta tags are only allowed within the head element, which doesn't allow noscript children.

    Besides, not all user agents support or allow meta redirects.
    Birnam wood is come to Dunsinane

  6. #6
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Allowed or not, that does work. Though I'm not saying this trick is particularly neat or even a good practice.

  7. #7
    SitePoint Zealot
    Join Date
    Sep 2007
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code JavaScript:
    <script type="text/javascript">
    document.location.href = "actual_page_to_load.html"
    </script>

    It's a thought


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
  •