Check if browser is NOT I.E.

Discussion in 'ASP General' started by David, Feb 25, 2004.

  1. David

    David Guest

    On a page optimised for IE, I'd like to check if the browser type is other
    than IE, so I can direct them to another page.

    How can I modify the code below to redirect to indextext.asp if they aren't
    using IE? I've tried changing the = for <>, but get a syntax error.

    Thanks

    USER_AGENT = Request.ServerVariables("HTTP_USER_AGENT")
    IS_IE = InStr(USER_AGENT,"MSIE")
    if IS_IE then
    response.redirect "indextext.asp"
    end if
    David, Feb 25, 2004
    #1
    1. Advertising

  2. David

    Bob Lehmann Guest

    > I hope this is not for a public website... browser sniffing is bad
    practice.

    Why do you say that?

    Bob Lehmann

    "Peter Foti" <> wrote in message
    news:...
    > "David" <> wrote in message
    > news:5q9%b.197$%...
    > > On a page optimised for IE, I'd like to check if the browser type is

    other
    > > than IE, so I can direct them to another page.
    > >
    > > How can I modify the code below to redirect to indextext.asp if they

    > aren't
    > > using IE? I've tried changing the = for <>, but get a syntax error.

    >
    > I hope this is not for a public website... browser sniffing is bad

    practice.
    >
    > Peter Foti
    >
    >
    Bob Lehmann, Feb 25, 2004
    #2
    1. Advertising

  3. David

    Lance Wynn Guest

    The code you posted works fine on my machine, what specific syntax error are
    you receiving?

    "David" <> wrote in message
    news:5q9%b.197$%...
    > On a page optimised for IE, I'd like to check if the browser type is other
    > than IE, so I can direct them to another page.
    >
    > How can I modify the code below to redirect to indextext.asp if they

    aren't
    > using IE? I've tried changing the = for <>, but get a syntax error.
    >
    > Thanks
    >
    > USER_AGENT = Request.ServerVariables("HTTP_USER_AGENT")
    > IS_IE = InStr(USER_AGENT,"MSIE")
    > if IS_IE then
    > response.redirect "indextext.asp"
    > end if
    >
    >
    Lance Wynn, Feb 25, 2004
    #3
  4. David

    David Guest

    "Lance Wynn" <> wrote in message
    news:%23vD0ES$%...
    > The code you posted works fine on my machine, what specific syntax error

    are
    > you receiving?


    The code I posted does work for detecting if it's IE - what I want to do is
    modify it to redirect the visitor to a different page if they are using a
    browser other that IE. If I change the = sign to <> (as below) , the browser
    comes up with "Syntax error" and points to the <>.

    Other points:- what on earth is "Browser sniffing"? I got the code from this
    forum in the first place in answer to a question on how I can direct
    visitors to pages optimised for their browser, and that is exactly what I
    use the code for. Why on earth is directing visitors to pages designed for
    their browser a bad thing????????

    Thanks,

    David

    USER_AGENT = Request.ServerVariables("HTTP_USER_AGENT")
    IS_IE <> InStr(USER_AGENT,"MSIE")
    if IS_IE then
    response.redirect "indextext.asp"
    end if
    David, Feb 26, 2004
    #4
  5. David

    jenny mabe Guest

    On Thu, 26 Feb 2004 06:54:18 -0000, David
    <> wrote:

    > The code I posted does work for detecting if it's IE - what I want to do
    > is modify it to redirect the visitor to a different page if they are
    > using a
    > browser other that IE. If I change the = sign to <> (as below) , the
    > browser comes up with "Syntax error" and points to the <>.


    did you mean to do something like this? there are a couple of syntax
    errors in the code you pasted.

    USER_AGENT = Request.ServerVariables("HTTP_USER_AGENT")
    IS_IE = InStr(USER_AGENT,"MSIE")
    if IS_IE <> 0 then
    response.redirect "indextext.asp"
    end if

    > Other points:- what on earth is "Browser sniffing"? I got the code from
    > this forum in the first place in answer to a question on how I can direct
    > visitors to pages optimised for their browser, and that is exactly what I
    > use the code for. Why on earth is directing visitors to pages designed
    > for their browser a bad thing????????


    i think it's something of an ideological thing -- it is ALWAYS better to
    write universally compatible code rather than code that requires you to
    have different pages for different browsers. also, the person whose namei
    cant remember pointed out quite rightly that some non-ie browsers, like
    opera which i use, can be set to spoof as internet explorer to avoid just
    those kinds of mechanisms (if i technically can see a page, i want the
    chance to do that, not be sent to a bare-bones version). it more or less
    undermines doing browser-sniffing -- checking the user's browser and
    coding differently for it -- in the first place.



    jenny
    jenny mabe, Feb 26, 2004
    #5
  6. "David" wrote:
    >
    > Why on earth is directing visitors to pages designed for
    > their browser a bad thing????????


    The need to redirect implies a deficiency in your "optimized for IE" page.
    This may, as Jenny suggests, be a matter of ideology, but believe me, the
    decision to code to standards rather than browsers will pay dividends down
    the line.

    I personally have no pity for users who access my sites with browsers that
    don't understand HTML 4, ECMAScript v3, DOM Level 1 (most of it, anyway) or
    CSS 1. Note that these are minima, and I do not DENY anyone on the basis of
    his browser. I merely lack respect for his browser choice and make no
    attempt to accommodate it. Those standards, after all, are each several
    years old.

    I partly accommodate those with scripting or cookies turned off, but often
    require one or both for users who want to use one of my *applications* with
    full functionality.

    What does "partly" mean here? One example is popup navigational menus. Our
    intranet site has them. But if the scripting to open the menu fails for any
    reason (such as crappy browser or scripting turned off), the user is sent to
    a page that lists all of the links in the drop-down menu.

    Does that user experience the full glory of our navigational menus? Who
    cares? Does he get the same opportunity to access information? Yes. And that
    is truly the only thing that matters when considering divergence from
    standards.



    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms. Please do not contact
    me directly or ask me to contact you directly for assistance. If your
    question is worth asking, it's worth posting.
    Dave Anderson, Feb 26, 2004
    #6
  7. David

    Bob Lehmann Guest

    > writing semantically correct code that can be displayed in all web
    browsers.
    To do that, you would be stuck with HTML 3.2, unless you determined the
    browser. Semantically correct code for NS7 may not work in NS4.x.

    Bob Lehmann

    "Peter Foti" <> wrote in message
    news:...
    > "Bob Lehmann" <none> wrote in message
    > news:evlohL$%...
    > > > I hope this is not for a public website... browser sniffing is bad

    > > practice.
    > >
    > > Why do you say that?

    >
    > For one, it's unreliable. Some browsers even let you input any user Agent
    > string you want. It also makes maintenance a nightmare. You are better

    off
    > writing semantically correct code that can be displayed in all web

    browsers.
    >
    > Regards,
    > Peter
    >
    >
    Bob Lehmann, Feb 26, 2004
    #7
  8. David

    Bob Lehmann Guest

    <iframe> perhaps?

    Bob Lehmann

    "Peter Foti" <> wrote in message
    news:...
    > "Bob Lehmann" <> wrote in message
    > news:ueV8y5G$...
    > > > writing semantically correct code that can be displayed in all web

    > > browsers.
    > > To do that, you would be stuck with HTML 3.2, unless you determined the
    > > browser. Semantically correct code for NS7 may not work in NS4.x.

    >
    > Huh?!!! What in the world are you talking about?! Semantically correct
    > code is far more likely to work in NS4 than not. Can you give me an

    example
    > of where this is not true?
    >
    > The closest I will ever come to browser sniffing is hiding my CSS from NS4
    > and letting it apply it's default presentation to semantically correct

    HTML,
    > since NS4 doesn't properly implement CSS. But this is NOT browser

    sniffing.
    >
    > Peter Foti
    >
    >
    Bob Lehmann, Feb 26, 2004
    #8
  9. David

    Lance Wynn Guest

    ok, sorry I misunderstood your problem,

    try:


    if not IS_IE then
    response.redirect "indextext.asp"
    end if


    The line IS_IE = InStr(USER_AGENT,"MSIE") sets the variable IS_IE to the
    results of the InStr function. the <> operator is a conditional operator,
    meaning it can only be used only be used in conditional statements (Like the
    IF statement) and cannot be used to set the value of a variable.

    Lance






    "David" <> wrote in message
    news:OKg%b.15$...
    >
    > "Lance Wynn" <> wrote in message
    > news:%23vD0ES$%...
    > > The code you posted works fine on my machine, what specific syntax error

    > are
    > > you receiving?

    >
    > The code I posted does work for detecting if it's IE - what I want to do

    is
    > modify it to redirect the visitor to a different page if they are using a
    > browser other that IE. If I change the = sign to <> (as below) , the

    browser
    > comes up with "Syntax error" and points to the <>.
    >
    > Other points:- what on earth is "Browser sniffing"? I got the code from

    this
    > forum in the first place in answer to a question on how I can direct
    > visitors to pages optimised for their browser, and that is exactly what I
    > use the code for. Why on earth is directing visitors to pages designed for
    > their browser a bad thing????????
    >
    > Thanks,
    >
    > David
    >
    > USER_AGENT = Request.ServerVariables("HTTP_USER_AGENT")
    > IS_IE <> InStr(USER_AGENT,"MSIE")
    > if IS_IE then
    > response.redirect "indextext.asp"
    > end if
    >
    >
    Lance Wynn, Feb 26, 2004
    #9
  10. David

    UncleWobbly Guest

    nonsense.

    what about capabilities or lack. I have a web-based application I support
    that uses client-side VBscript. I need to check the user is browsing with
    IE. Also, the same app has a page with three horizontal frames, the middle
    of which is composed of two vertical frames... Netscape doesn't like it, but
    I need to check otherwise the user sees a load of rubbish.

    not interested in the "my browser is better than your brower" argument. The
    app is designed for IE and not interested in supporting any other. The
    number of users this affects is tiny.


    "Peter Foti" <> wrote in message
    news:...
    > "David" <> wrote in message
    > news:5q9%b.197$%...
    > > On a page optimised for IE, I'd like to check if the browser type is

    other
    > > than IE, so I can direct them to another page.
    > >
    > > How can I modify the code below to redirect to indextext.asp if they

    > aren't
    > > using IE? I've tried changing the = for <>, but get a syntax error.

    >
    > I hope this is not for a public website... browser sniffing is bad

    practice.
    >
    > Peter Foti
    >
    >
    UncleWobbly, Feb 26, 2004
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joel Hedlund
    Replies:
    18
    Views:
    622
    Alex Martelli
    Sep 3, 2006
  2. Jason Stacy
    Replies:
    2
    Views:
    4,652
    Roedy Green
    Apr 27, 2008
  3. BL
    Replies:
    3
    Views:
    733
  4. Mike
    Replies:
    12
    Views:
    701
    Daniel Pitts
    Sep 26, 2008
  5. meagain
    Replies:
    1
    Views:
    279
    Evertjan.
    Mar 11, 2007
Loading...

Share This Page