473,385 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Check if browser is NOT I.E.

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
Jul 19 '05 #1
15 8265
"David" <da***@brown6669.freeserve.co.uk> wrote in message
news:5q**************@newsfep3-gui.server.ntli.net...
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
Jul 19 '05 #2
> I hope this is not for a public website... browser sniffing is bad
practice.

Why do you say that?

Bob Lehmann

"Peter Foti" <pe***@Idontwantnostinkingemailfromyou.com> wrote in message
news:10*************@corp.supernews.com...
"David" <da***@brown6669.freeserve.co.uk> wrote in message
news:5q**************@newsfep3-gui.server.ntli.net...
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

Jul 19 '05 #3
The code you posted works fine on my machine, what specific syntax error are
you receiving?

"David" <da***@brown6669.freeserve.co.uk> wrote in message
news:5q**************@newsfep3-gui.server.ntli.net...
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

Jul 19 '05 #4
"Bob Lehmann" <none> wrote in message
news:ev****************@tk2msftngp13.phx.gbl...
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
Jul 19 '05 #5

"Lance Wynn" <la********@N.O.S.P.A.M.hotmail.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
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
Jul 19 '05 #6
On Thu, 26 Feb 2004 06:54:18 -0000, David
<da***@brown6669.freeserve.co.uk> 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
Jul 19 '05 #7
"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.
Jul 19 '05 #8
> 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" <pe***@Idontwantnostinkingemailfromyou.com> wrote in message
news:10*************@corp.supernews.com...
"Bob Lehmann" <none> wrote in message
news:ev****************@tk2msftngp13.phx.gbl...
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

Jul 19 '05 #9
"Bob Lehmann" <no****@dontbotherme.zzz> wrote in message
news:ue*************@TK2MSFTNGP11.phx.gbl...
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
Jul 19 '05 #10
<iframe> perhaps?

Bob Lehmann

"Peter Foti" <pe***@Idontwantnostinkingemailfromyou.com> wrote in message
news:10*************@corp.supernews.com...
"Bob Lehmann" <no****@dontbotherme.zzz> wrote in message
news:ue*************@TK2MSFTNGP11.phx.gbl...
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

Jul 19 '05 #11
"David" <da***@brown6669.freeserve.co.uk> wrote in message
news:OK*************@newsfep3-gui.server.ntli.net...
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????????


Excellent points by Jenny and Dave. I agree with them... if you write
universally compatible code (coding to standards and validating with a
validator), you will be much better off, and your pages will be more
accessible. People with disabilities shouldn't be prevented from accessing
the same content as everyone else because they are using an aural browser
and not IE.

"The power of the Web is in its universality. Access by everyone regardless
of disability is an essential aspect."
-- Tim Berners-Lee, W3C Director and inventor of the World Wide Web

Regards,
Peter Foti
Jul 19 '05 #12
"Bob Lehmann" <none> wrote in message
news:el**************@TK2MSFTNGP11.phx.gbl...
<iframe> perhaps?


<IFRAME src="foo.html" width="400" height="500"
scrolling="auto" frameborder="1">
[Your user agent does not support frames or is currently configured
not to display frames. However, you may visit
<A href="foo.html">the related document.</A>]
</IFRAME>

This is the W3 recommended method. It's entirely backwards compatible.
Users that have an obsolete browser, or a browser that doesn't support
frames can still get to the content.

What else ya got? :)

Peter
Jul 19 '05 #13
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" <da***@brown6669.freeserve.co.uk> wrote in message
news:OK*************@newsfep3-gui.server.ntli.net...

"Lance Wynn" <la********@N.O.S.P.A.M.hotmail.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
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

Jul 19 '05 #14
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" <pe***@Idontwantnostinkingemailfromyou.com> wrote in message
news:10*************@corp.supernews.com...
"David" <da***@brown6669.freeserve.co.uk> wrote in message
news:5q**************@newsfep3-gui.server.ntli.net...
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

Jul 19 '05 #15
"UncleWobbly" <he***@talk21.com> wrote in message
news:40***********************@lovejoy.zen.co.uk.. .
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.


I'm not arguing any browser is better than another. In the case of using
VBScript on a public website... I think it's a bad idea, and I personally
would not do it (since there is only 1 browser that supports it). If it was
for an intranet application, where you have more control over how the app is
accessed... well, that's a different story.

In your case, the mistake is not browser sniffing... it's relying on client
side scripting as part of your primary content (and even worse, using a
scripting language that is only supported by 1 browser). Personally, I
would only rely on client side scripting for non-critical things, like bells
and whistles. So whether you use Javascript or VBScript, I think you're
making a mistake if you require it (though it may be that your particular
site does not care about accessibility... depends on your target audience I
suppose). There are better alternatives.

Regards,
Peter Foti

Jul 19 '05 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: TG | last post by:
This is more of a pain than I thought it would be. I need a simple code segment to determine whether a browser accepts cookies or not. When I pass variables between pages when cookies are turned...
4
by: mike parr | last post by:
I'm trying to do a check to see if the client browser has cookies enabled. But my code below always gives me the value for acceptsCookies = true, whether the machine has cookies enabled or not. ...
5
by: David Baker | last post by:
Hi all I am very new to ASP.Net. I am trying to create a sniffer for our program. We want our users to click our sniffer and hopefully the sniffer will check their computer against our...
0
by: Ayaz | last post by:
Hi All, I need to check the browser (IE) cookie permission, i.e. whether it is possible to create and read a cookie. I need to do that from a VB.NET winform application. For that, I have to...
22
by: petermichaux | last post by:
Hi, I would like to display a message to Internet Explorer clients to encorage them to get Firefox. Yes they may like Internet Explorer but it is my site :) http://www.explorerdestroyer.com/...
6
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I am thinking about doing this since I got several cases that some of our internal users open more than one browser at the same time from our server. When one of the transactions was not...
11
by: Anshul | last post by:
How can I check the current working browser from server side scripting or from HTML other than javascript. Can any body help. I dont want to use javascript to check the current working browser. ...
1
by: ilaxi kandoliya | last post by:
Hi, I have developing project with asp.net 2.0 (C#) I have used java script function in my code but if User's browser is java script disable then its not working properly so how to check Browser...
10
by: Conrad Lender | last post by:
In a recent thread in this group, I said that in some cases object detection and feature tests weren't sufficient in the development of cross-browser applications, and that there were situations...
11
by: Patrick | last post by:
Trying this question again in a different way and expanding it to another newsgroup. Looking for how I would do this. For an html form; Say I have three check boxes A, B, and C . When I click...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.