PDA

Click to See Complete Forum and Search --> : Javascript (basic?) problem ...


alex_read
Oct 2nd, 2000, 04:23 AM
Quick background info :
I am developing a vbs/web page which will be used as a personal site & will be the first full site I will have developed.
As it uses vbs, the user needs a version of IE to use & view it properly (not Netscape for example).

Problem :
Basically, I need some sample code in Javascript to :
1) Tell that the user is running IE.
2) If not, a messagebox appears telling them to get it
3) If so, navigate them to my starter page (i.e. - main.htm)

ANY help on this will be GREATLY appriciated. I do not want to learn another lanquage to vb (i.e. Java) as it may confuse me.

Thank you eveyone !

jdavison
Oct 2nd, 2000, 10:56 AM
try this

<script Language="JavaScript">
<!--
var capable;

capable = (navigator.appName == "Microsoft Internet Explorer");

if (capable) {
response.redirect("homepage");
}
else{
alert("you need IE");
response.redirect("ie site");
}

alex_read
Oct 3rd, 2000, 02:56 AM
Wow :D

Thank you for the quick reply jdavison ! Very much appriciated.

alex_read
Oct 3rd, 2000, 03:48 AM
jdavison, one quick question, can I have a very simple example of how you would fit a message box or alert to appear instead of the re-direction below.

Thank you for all of your help!

jdavison
Oct 3rd, 2000, 11:38 AM
just replace the redirect with the alert:

alert("your message here");

pnj
Oct 3rd, 2000, 03:36 PM
just curious but why can't the user use netscape?
I allways use netscape and view asp pages often.
I may be mistaken but isn't asp made w/ vbs?

jdavison
Oct 3rd, 2000, 03:55 PM
I dont believe netscape will handle client side vbscript. VbScript can be used instead of javascript on the client. I may be wrong on this.

jdavison
Oct 3rd, 2000, 03:58 PM
Alex,

You may want to just setup a simple page that runs just tat script and then redirects into your site. I have seen problems from trying to run VBscript and Javascript together on the same page.

pnj
Oct 3rd, 2000, 04:36 PM
I am new to this but why not use javascript on the client and vbscript on the server?
then both browser work for the same site.

alex_read
Oct 4th, 2000, 03:07 AM
:confused:

OK people, this is what I am (trying to) acomplish...


I heard that only Java works on netscape & not vbs. I don't want to learn java as I am concentrating on vb & don't want to confuse myself with another lanquage as from what I can see, vb goes into more or less everthing, games, web sites etc.

Client / Server side just confuses the b@!locks off me, all I am trying to do here is a personal web page - not on a server that any idiot can look at, nothing special like a company page.

This is the first page - purely Javascript to tell the user that if they have Netscape, my code won't work so come back when they have IE. This is the only page using the java bit, if the user has IE, then they are redirected to my fantastic site which purely uses vbs!


just to clear up few points there & bore you to death :D I thank you for all of your help everyone!

alex_read
Oct 4th, 2000, 05:23 AM
Hi everyone, I just cannot seen to get this one up & running, either with Jdavidson's code or my adapted :

<script Language="JavaScript">
<!--
var capable;

capable = (navigator.appName == "Microsoft Internet Explorer");

if (capable) {
response.redirect("www.microsoft.com");
}
else{
alert("The site has found that you are running an alternative to Microsoft's Internet Explorer" & Crlf & _
"This is essential to view this site as it is written in Visual Basic Script". & Crlf & _
"Please download this program at : http://www.microsoft.com/windows/ie/default.htm");

}


<!--######### DESIGNING #########-->
<HTML>
<HEAD>
<TITLE>ALEX'S HOME SITE</TITLE>

<FONT FACE="Comic Sans MS" SIZE=12>

Checking your browser configuration....
This should only take a few seconds.

</HEAD>
</HTML>


I don't think I have messed IE up, can anyone tell me what I have done wrong please?

Thank you for your patience.

jdavison
Oct 4th, 2000, 09:07 AM
Try it like this


<!--######### DESIGNING #########-->
<HTML>
<HEAD>
<TITLE>ALEXS HOME SITE</TITLE>


<script Language="JavaScript">
<!--
var capable;

capable = (navigator.appName == "Microsoft Internet Explorer");

if (capable) {
response.redirect("www.microsoft.com");
}
else{
alert("The site has found that you are running an alternative to Microsoft's Internet Explorer" & Crlf & _
"This is essential to view this site as it is written in Visual Basic Script". & Crlf & _
"Please download this program at : http://www.microsoft.com/windows/ie/default.htm");

}
-->
</script>
</HEAD>
<BODY>
<FONT FACE="Comic Sans MS" SIZE=12>

Checking your browser configuration....
This should only take a few seconds.

</BODY>
</HTML>

alex_read
Oct 4th, 2000, 10:31 AM
Thank you, all works now!