473,395 Members | 1,539 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,395 software developers and data experts.

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

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
4 1816
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

54
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO...
11
by: Troll | last post by:
Hi, This is related to my previous post but I made it much simpler... open (INFILE, "test.txt"); while (<>) { print $_; s/one/two/g; print $_; }
9
by: Vipul Jain | last post by:
Can any one please tell me what is the difference between global scope of an variable and file scope of an variable. Vipul
2
by: Steve | last post by:
I am new to this newsgroup & to .NET in general. I have been playing around with Visual Studio .NET, building and rendering web pages using VB "code behind" files. My problem / question is; How...
4
by: Larry Epn | last post by:
Simple question: I have a c# asp.net project that was given to me. It has the c# code within the <scriptsection of the global.asax file. I would rather have it in separate files; e.g.,...
1
by: ShaveDave27 | last post by:
Hi, I've created a Person Class with a comparable interface. And i've created an ArrayList People with varaibles from the person class in - First_name, Surname, Month(Birthday), Day(Birthday). Now...
15
by: =?Utf-8?B?UGF0Qg==?= | last post by:
Just starting to move to ASP.NET 2.0 and having trouble with the Global.asax code file. In 1.1 I could have a code behind file for the global.asax file. This allow for shared variables of the...
5
by: bimeldip | last post by:
Hi, I an tryin to create a html page where users can choose a file and open it however, i keep getting it wrong.So far this is wat i've worked on: (open.html) <html> <head> <title>Opening...
6
by: provor | last post by:
Hello, I have the following code that I am using when a user presses a button to import an excel file into a table. The code is hard coded to point to the correct table. This works great for this...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.