By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,516 Members | 1,176 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,516 IT Pros & Developers. It's quick & easy.

What's the comparable file in .js to Global.asa in ASP?

P: n/a
Hi, I need help badly. Sorry for my ignorance! What's the comparable
file in .js to Global.asa in ASP to capture the browser version (IE
vs. Netscape)? Any existing code to share or if you have a better way
to do it without using any server-side programming?

Can you write:
if (navigator.userAgent.indexOf("MSIE") != -1) as Client-side
programming within a HTML file instead of in a .js or .asp file? I
tried to write this piece of code in a HTML file, but it doesn't work.
So I am wondering about what's wrong. Thanks for your advice.

Helena
Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
In article <9c**************************@posting.google.com >, helena1995
@yahoo.com says...
Hi, I need help badly. Sorry for my ignorance! What's the comparable
file in .js to Global.asa in ASP to capture the browser version (IE
vs. Netscape)?
There isn't any. Global.asa isn't necessarily there to capture browser
info, though, is it?
Can you write:
if (navigator.userAgent.indexOf("MSIE") != -1) as Client-side
programming within a HTML file instead of in a .js or .asp file?


Yes.
<script type="text/javascript">
if (navigator.userAgent.indexOf("MSIE") != -1)
</script>

--
Hywel I do not eat quiche
http://hyweljenkins.co.uk/
http://hyweljenkins.co.uk/mfaq.php
Jul 20 '05 #2

P: n/a
And on the day 7 Oct 2003 15:16:01 -0700, he********@yahoo.com
enlightened us with <9c**************************@posting.google.com>. ..
Hi, I need help badly. Sorry for my ignorance! What's the comparable
file in .js to Global.asa in ASP to capture the browser version (IE
vs. Netscape)? Any existing code to share or if you have a better way
to do it without using any server-side programming?

Why would you want to?
It's much easier to capture objects instead and works in more than one
browser.
Also, testing for objects prevents problems like people who use IE4 or
if the IE for Mac didn't support something.
Can you write:
if (navigator.userAgent.indexOf("MSIE") != -1) as Client-side


Why?
IE5(.5?)+ has document.all as well as document.getElementById. As does
Opera (if you set it to). To make a script that works in all browsers
that support those constructs (there may be more), you'd do

if (document.all && document.getElementById)

Heck, if you don't have to support all browsers, you can just test for
document.getElementById and pop an alert for all the others. That would
make it work in IE5.5+, NN6+, Mozilla, Opera (6?)+...

--------------------------------------------------
~kaeli~
Kill one man and you are a murderer. Kill millions
and you are a conqueror. Kill everyone and you
are God.
http://www.ipwebdesign.net/wildAtHeart/
http://www.ipwebdesign.net/kaelisSpace/
------------------------------------------------
Jul 20 '05 #3

P: n/a
Thanks a lot. What I was trying to do is the following: opening a file
in different ways when dealing with different browsers. So would your
code work for this function? Bear with me, a greener, for the
ignorance.
<script language="JavaScript">
function doWord(file)
{

if (navigator.userAgent.indexOf("MSIE")!=-1)
{
var w = new ActiveXObject("Word.Application");
if (w != null)
{
w.Visible = true;

w.Documents.Open(file);

}
}
else
{
document.write(...)
}
}
</script>

kaeli <in********************@NOSPAMatt.net> wrote in message news:<MP************************@netnews.worldnet. att.net>... And on the day 7 Oct 2003 15:16:01 -0700, he********@yahoo.com
enlightened us with <9c**************************@posting.google.com>. ..
Hi, I need help badly. Sorry for my ignorance! What's the comparable
file in .js to Global.asa in ASP to capture the browser version (IE
vs. Netscape)? Any existing code to share or if you have a better way
to do it without using any server-side programming?


Why would you want to?
It's much easier to capture objects instead and works in more than one
browser.
Also, testing for objects prevents problems like people who use IE4 or
if the IE for Mac didn't support something.
Can you write:
if (navigator.userAgent.indexOf("MSIE") != -1) as Client-side


Why?
IE5(.5?)+ has document.all as well as document.getElementById. As does
Opera (if you set it to). To make a script that works in all browsers
that support those constructs (there may be more), you'd do

if (document.all && document.getElementById)

Heck, if you don't have to support all browsers, you can just test for
document.getElementById and pop an alert for all the others. That would
make it work in IE5.5+, NN6+, Mozilla, Opera (6?)+...

--------------------------------------------------
~kaeli~
Kill one man and you are a murderer. Kill millions
and you are a conqueror. Kill everyone and you
are God.
http://www.ipwebdesign.net/wildAtHeart/
http://www.ipwebdesign.net/kaelisSpace/
------------------------------------------------

Jul 20 '05 #4

P: n/a
And on the day 8 Oct 2003 12:04:30 -0700, he********@yahoo.com
enlightened us with <9c**************************@posting.google.com>. ..
Thanks a lot. What I was trying to do is the following: opening a file
in different ways when dealing with different browsers. So would your
code work for this function? Bear with me, a greener, for the
ignorance.


Most browsers won't allow you to use javascript to open a file. IE will
under some circumstances (lowered security, ActiveX, etc).
Normal security settings don't allow for the opening of a file with
javascript because it runs on the client and that would be a bad thing
for malicious people to be able to do. When using server-side script to
open a file on the server, the browser is irrelevant.

What file do you need to open? Is this for a CD, intranet application,
active desktop, or...? If you're making something for a CD, you could
use an HTA - it gets better permissions. I think Windows as the OS is
required to use an HTA.

--------------------------------------------------
~kaeli~
Kill one man and you are a murderer. Kill millions
and you are a conqueror. Kill everyone and you
are God.
http://www.ipwebdesign.net/wildAtHeart/
http://www.ipwebdesign.net/kaelisSpace/
------------------------------------------------
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.