473,473 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

a script for each browser ?

Hi,

I would like to write a script that will load a js file according to the
browser used.
Here is the suggested code :

****
function detectBrowser()
{
var browser=navigator.appName;
if ((browser=="Netscape"))
{
Load the netscape.js file;
}
else
{
load others.js;
}
}
*****
So, how could I code the "load the *js code" ?
Thanks for your help.
Rémi.

Dec 5 '07 #1
15 1421
remi said the following on 12/5/2007 5:59 PM:
Hi,

I would like to write a script that will load a js file according to the
browser used.
Why?
Here is the suggested code :
Throw it away, it is junk.
****
function detectBrowser()
{
var browser=navigator.appName;
There is your first problem. Attempting to identify *anything* based on
the navigator.appName
So, how could I code the "load the *js code" ?
First, you might try explaining why you think you need two .js files to
start with.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 5 '07 #2
remi wrote:
****
function detectBrowser()
{
var browser=navigator.appName;
if ((browser=="Netscape"))
{
Load the netscape.js file;
}
else
{
load others.js;
}
}
*****
So, how could I code the "load the *js code" ?
Thanks for your help.
What would you do differently for Netscape?
Mick
Dec 5 '07 #3
Le Wed, 05 Dec 2007 18:31:09 -0500, Randy Webb a écritÂ*:
remi said the following on 12/5/2007 5:59 PM:
>Hi,

I would like to write a script that will load a js file according to
the browser used.

Why?
>Here is the suggested code :

Throw it away, it is junk.
>****
function detectBrowser()
{
var browser=navigator.appName;

There is your first problem. Attempting to identify *anything* based on
the navigator.appName
>So, how could I code the "load the *js code" ?

First, you might try explaining why you think you need two .js files to
start with.
Ok, it is a bit special. The aim is to be able to render dynamic SVG
files (SMIL animation). SVG is into a XHTML file.

Opera renders them properly (for the use I need)
Firefox and others not yet (IE never) except if I load a script called
smilScript.js that will emulate rendering engine by script.

The matter is that if I have the script loaded into Opera, the animation
are a bit buggy and slow. I think that the script conflicts with Opera's
built-in rendering engine.

So I would like to only load this great script if needed that is to say
if the browser is not Opera.

Thanks for your replies.
Rémi.

Dec 6 '07 #4
rémi said the following on 12/6/2007 11:01 AM:
Le Wed, 05 Dec 2007 18:31:09 -0500, Randy Webb a écrit :
>remi said the following on 12/5/2007 5:59 PM:
>>Hi,

I would like to write a script that will load a js file according to
the browser used.
Why?
>>Here is the suggested code :
Throw it away, it is junk.
>>****
function detectBrowser()
{
var browser=navigator.appName;
There is your first problem. Attempting to identify *anything* based on
the navigator.appName
>>So, how could I code the "load the *js code" ?
First, you might try explaining why you think you need two .js files to
start with.

Ok, it is a bit special. The aim is to be able to render dynamic SVG
files (SMIL animation). SVG is into a XHTML file.

Opera renders them properly (for the use I need)
Firefox and others not yet (IE never) except if I load a script called
smilScript.js that will emulate rendering engine by script.

The matter is that if I have the script loaded into Opera, the animation
are a bit buggy and slow. I think that the script conflicts with Opera's
built-in rendering engine.

So I would like to only load this great script if needed that is to say
if the browser is not Opera.
I think you want to load it if it supports SVG, irregardless of what
browser it is. That means you test for support (and the .js file should
do that). Then, it doesn't matter what browser it is. If it supports
what you want to do, then it supports it. If it doesn't, then it falls
back out.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 6 '07 #5
Le Thu, 06 Dec 2007 12:07:24 -0500, Randy Webb a écritÂ*:
rémi said the following on 12/6/2007 11:01 AM:
>Le Wed, 05 Dec 2007 18:31:09 -0500, Randy Webb a écrit :
>>remi said the following on 12/5/2007 5:59 PM:
Hi,

I would like to write a script that will load a js file according to
the browser used.
Why?

Here is the suggested code :
Throw it away, it is junk.

****
function detectBrowser()
{
var browser=navigator.appName;
There is your first problem. Attempting to identify *anything* based
on the navigator.appName

So, how could I code the "load the *js code" ?
First, you might try explaining why you think you need two .js files
to start with.

Ok, it is a bit special. The aim is to be able to render dynamic SVG
files (SMIL animation). SVG is into a XHTML file.

Opera renders them properly (for the use I need) Firefox and others not
yet (IE never) except if I load a script called smilScript.js that will
emulate rendering engine by script.

The matter is that if I have the script loaded into Opera, the
animation are a bit buggy and slow. I think that the script conflicts
with Opera's built-in rendering engine.

So I would like to only load this great script if needed that is to say
if the browser is not Opera.

I think you want to load it if it supports SVG, irregardless of what
browser it is. That means you test for support (and the .js file should
do that). Then, it doesn't matter what browser it is. If it supports
what you want to do, then it supports it. If it doesn't, then it falls
back out.
Yes you are right, but I know wich browser natively support it. At the
moment there is only opera. Some others can do it with a plugin. So
navigator.appName should do the job (?).

BTW, I don't have a clue on how to test, with a script, if a feature is
supported or not.
Thanks.
Rémi.

Dec 6 '07 #6
On Dec 6, 12:23 pm, rémi <nos...@merci.comwrote:
Le Thu, 06 Dec 2007 12:07:24 -0500, Randy Webb a écrit :
rémi said the following on 12/6/2007 11:01 AM:
Le Wed, 05 Dec 2007 18:31:09 -0500, Randy Webb a écrit :
>remi said the following on 12/5/2007 5:59 PM:
Hi,
>>I would like to write a script that will load a js file according to
the browser used.
Why?
>>Here is the suggested code :
Throw it away, it is junk.
>>****
function detectBrowser()
{
var browser=navigator.appName;
There is your first problem. Attempting to identify *anything* based
on the navigator.appName
>>So, how could I code the "load the *js code" ?
First, you might try explaining why you think you need two .js files
to start with.
Ok, it is a bit special. The aim is to be able to render dynamic SVG
files (SMIL animation). SVG is into a XHTML file.
Opera renders them properly (for the use I need) Firefox and others not
yet (IE never) except if I load a script called smilScript.js that will
emulate rendering engine by script.
The matter is that if I have the script loaded into Opera, the
animation are a bit buggy and slow. I think that the script conflicts
with Opera's built-in rendering engine.
So I would like to only load this great script if needed that is to say
if the browser is not Opera.
I think you want to load it if it supports SVG, irregardless of what
browser it is. That means you test for support (and the .js file should
do that). Then, it doesn't matter what browser it is. If it supports
what you want to do, then it supports it. If it doesn't, then it falls
back out.

Yes you are right, but I know wich browser natively support it. At the
moment there is only opera. Some others can do it with a plugin. So
navigator.appName should do the job (?).
The navigator.appName property is worthless. If you really have such
a special case that you need to exclude only Opera, and assuming there
is no feature detection for the required level of SVG support, you can
test for the global opera object. Before you resort to that though,
you should think if there are specific SVG features that are present
in Opera, but not in the other browsers.
>
BTW, I don't have a clue on how to test, with a script, if a feature is
supported or not.
You should learn how to do that first. Do you at least know how to
test if a feature is present? If present, features can be tried and
sometimes results can be measured in a way that differentiates proper
implementations from broken ones.
Dec 6 '07 #7
In comp.lang.javascript message <9s*********************@giganews.com>,
Wed, 5 Dec 2007 18:31:09, Randy Webb <Hi************@aol.composted:
>remi said the following on 12/5/2007 5:59 PM:
>Hi,
I would like to write a script that will load a js file according to
the browser used.

Why?
>Here is the suggested code :

Throw it away, it is junk.
>****
function detectBrowser()
{
var browser=navigator.appName;

There is your first problem. Attempting to identify *anything* based on
the navigator.appName
>So, how could I code the "load the *js code" ?

First, you might try explaining why you think you need two .js files to
start with.

Rather than being merely grumpy in your reply, why not be constructive
and give a direct citation of a useful reference? FAQ 4.26, for
example.

<FAQENTRYIn FAQ 4.26, insert "correctly" before "supported"; and add
else /* ??? */
to the code.

The page that you cite in sig line 4 is a poor example of best practices
in general, as it fails Opera Ctrl-Alt-V W3 HTML validation in a manner
which appears largely fixable without loss of functionality. And the
page that you cite in sig line 3 is only tentatively valid.

Firefox is now 2.0.0.11.

BTW, why do you cite in the FAQ pages that you cannot understand? The
only logical reason for that would be an expectation that FAQ readers
are smarter than you are.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "" (SonOfRFC1036)
Dec 6 '07 #8
rémi wrote:
Le Thu, 06 Dec 2007 12:07:24 -0500, Randy Webb a écrit :
>I think you want to load it if it supports SVG, irregardless of what
browser it is. That means you test for support (and the .js file should
do that). Then, it doesn't matter what browser it is. If it supports
what you want to do, then it supports it. If it doesn't, then it falls
back out.

Yes you are right, but I know wich browser natively support it.
You don't even know a small subset of those.
At the moment there is only opera.
Your information is heavily outdated. Example, all Gecko 1.8+ based UAs
support it natively, too. That includes, for example, Firefox 1.5+ (1.5
was released on 2005-11-29).

http://www.mozilla.org/projects/svg/status.html
[...]
So navigator.appName should do the job (?).
Never ever does it. http://PointedEars.de/scripts/test/whatami
BTW, I don't have a clue on how to test, with a script, if a feature is
supported or not.
I doubt that for this feature test you will need client-side scripting at
all. HTML provides for intrinsic fallback.
PointedEars
--
"Use any version of Microsoft Frontpage to create your site. (This won't
prevent people from viewing your source, but no one will want to steal it.)"
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Dec 6 '07 #9
Le Thu, 06 Dec 2007 22:15:57 +0100, Thomas 'PointedEars' Lahn a écrit:
rémi wrote:
>Le Thu, 06 Dec 2007 12:07:24 -0500, Randy Webb a écrit :
>>I think you want to load it if it supports SVG, irregardless of what
browser it is. That means you test for support (and the .js file
should do that). Then, it doesn't matter what browser it is. If it
supports what you want to do, then it supports it. If it doesn't, then
it falls back out.

Yes you are right, but I know wich browser natively support it.

You don't even know a small subset of those.
>At the moment there is only opera.

Your information is heavily outdated. Example, all Gecko 1.8+ based UAs
support it natively, too. That includes, for example, Firefox 1.5+ (1.5
was released on 2005-11-29).

http://www.mozilla.org/projects/svg/status.html
I am talking about declarative animation in SVG. Not static SVG.
You can have a look here at the Animation Module part of the page you
mentionned.

I know that the only browser to support it a the moment (natively) is
Opera.

It is the reason why this choice to detect browser name is good for me.

To be frank, I am very eager to have it supported in FF that I used much
more.
>
>[...]
So navigator.appName should do the job (?).

Never ever does it. http://PointedEars.de/scripts/test/whatami
Thanks for this link.
For my use, it doesn't matter is a user wants to fake navigator.appName
or navigator.userAgent
He won't have the animation working properly. What do you think of that
apples ? ;-)
My script is not intended to be used commercialy or event
professionnaly ! It is just for me and a few geeks willing to spend spare
time palying with computers.

All I need to know is how to load a script if navigator.appName is
Netscape.

I know this is junk, evil and I will flagelate myslef for hours because I
have done this great sin. Oh Lord, pardon me but... Do I have the
choice ? ;-)

Rémi.

Dec 7 '07 #10
On Dec 7, 9:28 am, remi <r...@nospam.orgwrote:
Le Thu, 06 Dec 2007 22:15:57 +0100, Thomas 'PointedEars' Lahn a écrit:
rémi wrote:
Le Thu, 06 Dec 2007 12:07:24 -0500, Randy Webb a écrit :
I think you want to load it if it supports SVG, irregardless of what
browser it is. That means you test for support (and the .js file
should do that). Then, it doesn't matter what browser it is. If it
supports what you want to do, then it supports it. If it doesn't, then
it falls back out.
Yes you are right, but I know wich browser natively support it.
You don't even know a small subset of those.
At the moment there is only opera.
Your information is heavily outdated. Example, all Gecko 1.8+ based UAs
support it natively, too. That includes, for example, Firefox 1.5+ (1.5
was released on 2005-11-29).
http://www.mozilla.org/projects/svg/status.html

I am talking about declarative animation in SVG. Not static SVG.
You can have a look here at the Animation Module part of the page you
mentionned.

I know that the only browser to support it a the moment (natively) is
Opera.

It is the reason why this choice to detect browser name is good for me.

To be frank, I am very eager to have it supported in FF that I used much
more.
[...]
So navigator.appName should do the job (?).
Never ever does it. http://PointedEars.de/scripts/test/whatami

Thanks for this link.
For my use, it doesn't matter is a user wants to fake navigator.appName
or navigator.userAgent
He won't have the animation working properly. What do you think of that
apples ? ;-)
Rotten. Never mind users. IE has spoofed Mozilla since the mid 90's.
My script is not intended to be used commercialy or event
professionnaly ! It is just for me and a few geeks willing to spend spare
time palying with computers.

All I need to know is how to load a script if navigator.appName is
Netscape.
How about if it is not Opera? I gave you the answer to that if you
want to resort to browser sniffing (!window.opera.)
Dec 7 '07 #11
Thanks for your reply,

Le Fri, 07 Dec 2007 10:09:34 -0800, David Mark a écritÂ*:
On Dec 7, 9:28 am, remi <r...@nospam.orgwrote:
[...]
>All I need to know is how to load a script if navigator.appName is
Netscape.

How about if it is not Opera? I gave you the answer to that if you want
to resort to browser sniffing (!window.opera.)
If it is Firefox : I need to load a script to emulate declarative
animation.

If it is Opera, that's OK : declarative animation in SVG are enough
supported for my use and I don't have to load a script (I must not to be
frank)

If it is IE : i dont' know/care as my users (me, myself, I and a few
unoccopied and polite enough friends) are on FF or Opera.
If it is other browser : need to try
If someone has spoofed appname : lol well done you cOwb0yZ ;-)

So anyone could tell me how to complete this piece of junk ?
****
function NoobWhoWroteThisWantsToDetectBrowserLol()
{
var browser=navigator.appName;
if ((browser=="Netscape"))
{
Load the netscape.js file;
}
else
{
load nothing and let things go !
}
}
*****
I promise I won't advice this to another noob who dare to ask !
Thanks ;-)
Rémi.

Dec 9 '07 #12
Dr J R Stockton said the following on 12/6/2007 7:43 AM:
In comp.lang.javascript message <9s*********************@giganews.com>,
Wed, 5 Dec 2007 18:31:09, Randy Webb <Hi************@aol.composted:
>remi said the following on 12/5/2007 5:59 PM:
>>Hi,
I would like to write a script that will load a js file according to
the browser used.
Why?
>>Here is the suggested code :
Throw it away, it is junk.
>>****
function detectBrowser()
{
var browser=navigator.appName;
There is your first problem. Attempting to identify *anything* based on
the navigator.appName
>>So, how could I code the "load the *js code" ?
First, you might try explaining why you think you need two .js files to
start with.


Rather than being merely grumpy in your reply, why not be constructive
and give a direct citation of a useful reference? FAQ 4.26, for example.
Yessuh Mastah, I dew whut yew want.
<FAQENTRYIn FAQ 4.26, insert "correctly" before "supported"; and add
else /* ??? */
to the code.
FAQ5.1, paragraph 1, last sentence.
The page that you cite in sig line 4 is a poor example of best practices
in general, as it fails Opera Ctrl-Alt-V W3 HTML validation in a manner
which appears largely fixable without loss of functionality. And the
page that you cite in sig line 3 is only tentatively valid.
Then sue me.
Firefox is now 2.0.0.11.
That's nice. Need a URL?
BTW, why do you cite in the FAQ pages that you cannot understand? The
only logical reason for that would be an expectation that FAQ readers
are smarter than you are.
I owe you an apology. I was wrong. You are dumber than I though you were.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 10 '07 #13
You might want to consider the free BrowserObject component at
http://www.browserobject.com

It provides browser detection as .NET component.
Dec 11 '07 #14
On Dec 11, 1:08 am, mkwong8...@hotmail.com wrote:
You might want to consider the free BrowserObject component athttp://www.browserobject.com

It provides browser detection as .NET component.
That is doubly worthless.
Dec 11 '07 #15
mk********@hotmail.com wrote:
You might want to consider the free BrowserObject component at
http://www.browserobject.com

It provides browser detection as .NET component.
Break, fly, wheel.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Dec 11 '07 #16

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

Similar topics

10
by: Don | last post by:
I want the server-side php script to return a browser page that is essentially a copy of the original client page that contained the <form> which referenced the php script in the first place....
8
by: Johnny Knoxville | last post by:
I've added a favicon to my site (http://lazyape.filetap.com/) which works fine if you add the site to favourites the normal way, but I have some JavaScript code on a couple of pages with a link,...
1
by: cwdjrxyz | last post by:
I am now writing many new pages in xhtml 1.1. They are served as true xhtml by setting the mime type of the server to application/xhtml+xml for the .xhtml extension. Since IE6 and some earlier...
4
by: petermichaux | last post by:
Hi, I'm hoping for a reason I'm wrong or an alternate solution... I'd like to be able to dynamically include some javascript files. This is like scriptaculous.js library but their solution is...
17
by: PJ | last post by:
Greetings... I have stumbled upon a small problem. I use Ajax to retrieve part of a page I need to update. I update a DIV element with the HTML contents I get from another page. It works...
15
by: Lennart | last post by:
Hi folks, I have created an animated image gallery in dhtml. It works fine in Internet Explorer. In Firefox, it only works if I ommit the DOCTYPE tag. The page is valid xhtml-strict but with a...
5
by: Bjorn Sagbakken | last post by:
Hello I have just migrated from VS 2003 to VS 2005, and .NET framework 1.1 to 2.0 I am at the end of debugging and fixing stuff. Now there is one error I just cannot find a solution to: On...
28
by: Peter Michaux | last post by:
Hi, I'm playing with dynamic script insertion to make a request to the server for a JavaScript file to be automatically run when it arrives in the browser. It works but... The page caching...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.