Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checking the browser

Status
Not open for further replies.

crystalized

Programmer
Jul 10, 2000
390
CA
I currently have an application that is created using all server side scripting (I am new to ASP so I thought I would keep things simple to start).

Since I am using Visual Interdev all of the buttons I have been using are button DTC's, and the actions for the buttons are also server side.

Now my problem is that I do not want anyone to get past the login screen if they are using Netscape. The forms I have created should only be accessed with Internet Explorer. I think that (according to what I remember), you can use javascript to check the browser type. So what I would like to do is add that ability to my asp page.

I know that I have read posts that discuss this on one of the forums but I have done a search or two and could not find what I was looking for.

If anyone can offer me any advice on this topic I would really appreciate it. Thanks in advance.



[sig]<p>Crystal<br><a href=mailto:crystals@genesis.sk.ca>crystals@genesis.sk.ca</a><br><a href= > </a><br>--------------------------------------------------<br>
Experience is one thing you can't get for nothing.<br>
-Oscar Wilde<br>
[/sig]
 
Crystal

One way (there are lots) is this

set objBC=Server.CreateObject(&quot;MSWC.BrowserType&quot;)
if objBC.browser = &quot;IE&quot; then
.... whatever for IE
else
.... Others
end if

Not one of the best, but it would do what you want. Does rely on a file called &quot;browscap.ini&quot; that defines all the various browser types. Since you get one from Microsoft by default and you only wnt IE then it should all hang together! Searching on the above topics should explain further.

Ibby
[sig][/sig]
 
Crystal,
Here's a client side solution. Essentially, you check to make sure that the user has IE, and if so, generate the login code, otherwise display a message to get IE:
Code:
<html><head></head><body><form>
<script language='Javascript'>
if (document.all) 
   {
   var out = &quot;<center>UserName:<input type='text' name='userid'><br>&quot;
           + &quot;Password:<input type='password' name='pwd'><br>&quot;
           + &quot;<input type='submit' value='Login'></center>&quot;
   document.writeln(out);
   }
else
   {
   document.writeln(&quot;Sorry,  you need IE to use this site&quot;);
   }
</script></form></body></html>
[sig]<p>nick bulka<br><a href=mailto: > </a><br><a href= </a><br>Get your technical books at Bulka's Books<br>
[/sig]
 
Thanks to both of you, this gives me two directions I can explore which is always nice. I very much appreciate the help. [sig]<p>Crystal<br><a href=mailto:crystals@genesis.sk.ca>crystals@genesis.sk.ca</a><br><a href= > </a><br>--------------------------------------------------<br>
Experience is one thing you can't get for nothing.<br>
-Oscar Wilde<br>
[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top