Web Analytics Made Easy -
StatCounter Anybody know this script? - CodingForum

Announcement

Collapse
No announcement yet.

Anybody know this script?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Anybody know this script?

    Does anybody know a script that blocks vistors using a specific browser from viewing a website?

  • #2
    Enclosing all of your web page body inside the following tags will make the page blank for anyone not using IE5+.

    <!--[if IE]> <[endif]-->

    To make it blank for anyone who is using IE5+ you would enclose it in the following tags

    <!--[if !IE]--> <!--[endif]-->

    Internet Explorer is the only browser that provides any way to identify the actual browser being used so you can't positively identify any of the thousands of other browsers out there. Most so called browser detection scripts look at the useragent which identifies the browser as whatever the browser claims to be rather than what it actually is.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

    Comment


    • #3
      This sounds rather useful if you have IE, or other content. I am thinking if using rational thought here, couldn't you do this:

      Code:
      <!--[if IE]>
      Here is the code to display
      <!--[else]>
      Please use Internet Explorer to view this page
      <!--[endif]>

      Comment


      • #4
        No, [else] is not supported.

        <!--[if IE]>
        Here is the code to display
        <!--[endif]>
        <!--[if !IE]>
        <p>Please use Internet Explorer to view this page</p>
        <!--[endif]>

        All the code given in this post has been tested and is intended to address the question asked.
        Unless stated otherwise it is not just a demonstration.

        Comment


        • #5
          You need to get the code set up to properly mark the start and end of the comments for the browsers that are not IE and which therefore don't understand the if statements.

          <!--[if IE]>
          <p>IE only page content</p>
          <[endif]-->
          <!--[if !IE]-->
          <p>The browser you are using follows the standards too closely to properly display this page. Please downgrade to Internet Exploder to view this page the way it is intended.</p>
          <!--[endif]-->
          Stephen
          Learn Modern JavaScript - http://javascriptexample.net/
          Helping others to solve their computer problem at http://www.felgall.com/

          Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

          Comment

          Working...
          X