SitePoint Sponsor

User Tag List

Results 1 to 18 of 18
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2005
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    checking for browser

    Hi,
    I´m doing check for browser allowing only IE to pass through, redirecting the others to a error page. But when a Firefox with No-Scripts extension opens the page, the js browser check doesn´t load, so it opens normaly.
    How can I check for js support, to add to my if clause, so the firefox with No-Scrip also is redirected to error page?

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi mjunior,

    Without seeing your code I can't really suggest much, but if it were me I'd probably use JScript conditional compilation.

  3. #3
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    /*@cc_on
    @if (@_jscript) // any version of IE
      // ...code for IE...
    @else @*/
      // ...code for non-IE...
    /*@end @*/

  4. #4
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So why are you only supporting IE?
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  5. #5
    SitePoint Zealot
    Join Date
    Mar 2005
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kravvitz View Post
    So why are you only supporting IE?
    yeah I know that you advise just the oposite, but by now all the layouts and designed pages made by others to our intranet were made and tested only in IE, so it'' ll be a hell of a work to compliance them all at the moment.

    The checking I'm doing now is:
    function detectBrowser(){var browser=navigator.appName
    var b_version=navigator.appVersion
    var version=parseFloat(b_version)
    if ((browser!="Microsoft Internet Explorer")
    && (version>4)) {window.location='browser.asp?msg=browser'}
    }

  6. #6
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So why don't you want to allow people to see the broken pages if they want to see them?
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  7. #7
    SitePoint Guru
    Join Date
    Apr 2007
    Posts
    813
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So why don't you want to allow people to see the broken pages if they want to see them?
    haha it is just a matter of preference. No big deals to hide ugly things and prevent it to be shown.

  8. #8
    SitePoint Zealot
    Join Date
    Mar 2005
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So, what should I add to my " if " statement to prevent from no js enable on the browsers?

  9. #9
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,807
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Why not just surround all the body of your page inside an IE conditional so that the page looks blank to anyone using a proper web browser.

    <body><!--[if IE]>
    <p>this content will only show in Internet Exploder.</p>
    <![endif]--></body>
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  10. #10
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem with that would be if you had any HTML comments in the content of the page.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  11. #11
    SitePoint Zealot the DtTvB's Avatar
    Join Date
    Jul 2006
    Location
    Thailand
    Posts
    162
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you wanted to kick non-IE users out, you can use:
    Code:
    <![if !IE]><meta http-equiv="refresh" content="0;url=http://www.google.com/" /><![endif]>
    Note that it will make your page invalid. W3C validator won't accept this.

  12. #12
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mjunior View Post
    So, what should I add to my " if " statement to prevent from no js enable on the browsers?
    Nothing - because if the browser doesn't have JavaScript enabled then your function will never run.
    Ian Anderson
    www.siteguru.co.uk

  13. #13
    SitePoint Guru Ize's Avatar
    Join Date
    Nov 2005
    Location
    The Netherlands
    Posts
    808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by the DtTvB View Post
    If you wanted to kick non-IE users out, you can use:
    Code:
    <![if !IE]><meta http-equiv="refresh" content="0;url=http://www.google.com/" /><![endif]>
    Note that it will make your page invalid. W3C validator won't accept this.
    Considering the site only works in IE and it's too much work to make it behave in other browsers, I doubt it'll validate in the first place
    Quote Originally Posted by siteguru View Post
    Nothing - because if the browser doesn't have JavaScript enabled then your function will never run.
    Good point. There's no way you can use a Javascript function to redirect a user when Javascript is disabled

    Anyway, I'd do as Kravvitz suggested; just show the broken page. Why go out of your way to prevent this?

    Also, I like this approach by Dean Edwards.

  14. #14
    SitePoint Zealot
    Join Date
    Dec 2006
    Posts
    182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just let people see it and let it render poorly - better they get ugly content than no content.

  15. #15
    SitePoint Guru
    Join Date
    Apr 2007
    Posts
    813
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, it is better to notify them switching to another browser

  16. #16
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,807
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Some people don't get a choice of browser when their particular disability means that the one they are using is the only one that they can make work properly for them. Anyway, people should be able to choose the browser that they want to use and if enough of them use a crappy non-standard browser you have to patch your page so that it works there as well as in decent modern standard compliant browsers. (on second thoughts let's all not patch our sites to work with the non-standard browsers and maybe that will force people to abandon IE7).
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  17. #17
    SitePoint Zealot
    Join Date
    Mar 2005
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So there&#180;s no way, right?

  18. #18
    SitePoint Member
    Join Date
    Jun 2006
    Location
    Australia
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No i think of a single way to do this and nor should there be


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
  •