每个浏览器的脚本? [英] a script for each browser ?
问题描述
我想编写一个脚本,根据使用的
浏览器加载一个js文件。
以下是推荐代码:
****
函数detectBrowser()
{
var browser = navigator.appName;
if((browser ==" Netscape"))
{
加载netscape .js文件;
}
其他
{
加载others.js;
}
}
*****
那么,我怎么能编码加载* js代码呢? ?
感谢您的帮助。
R ?? mi。
< blockquote> remi在12/5/2007 5:59 PM发表以下内容:
我想要编写一个脚本,根据所使用的
浏览器加载一个js文件。
为什么?
以下是建议代码:
扔掉它,它是垃圾。
****
function detectBrowser()
{
var browser = navigator.appName;
第一个问题。尝试识别*任何*基于
navigator.appName
那么,我怎么能编码加载* js代码 ; ?
首先,您可以尝试解释为什么您认为需要两个.js文件才能开始使用。
/ >
-
兰迪
机会有利于预备心灵
comp.lang.javascript常见问题 - http://jibbering.com/faq/index.html
Javascript最佳实践 - http://www.JavascriptToolbox.com/bestpractices/
remi写道:
****
function detectBrowser()
{
var browser = navigator.appName;
if((browser ==" Netscape"))
{
加载netscape.js文件;
}
else
{
加载others.js;
}
}
*****
所以,我怎么能编码加载* js代码" ?
感谢您的帮助。
对于Netscape你会做些什么?
Mick
Le Wed ,2007年12月5日18:31:09 -0500,Randy Webb a ??暴击?*:
remi在12/5/2007 5:59上发表以下内容PM:
>
我想写一个脚本,根据
加载一个js文件浏览器使用。
为什么?
>以下是建议的代码:
扔掉它,它是垃圾。
> ****
函数detectBrowser()
{
var browser = navigator.appName;
你的第一个问题。尝试识别*任何*基于
navigator.appName
>那么,我怎么能编码加载* js代码 ?
首先,你可以尝试解释为什么你认为你需要两个.js文件来开始。
好的,它有点特别。目的是能够渲染动态SVG
文件(SMIL动画)。 SVG是一个XHTML文件。
Opera正确呈现它们(供我需要使用)
Firefox和其他人还没有(IE从未)除非我加载一个名为
smilScript.js的脚本,它将通过脚本模拟渲染引擎。
问题是如果我将脚本加载到Opera中,动画
有点马车和慢。我认为这个脚本与Opera的内置渲染引擎相冲突。
所以我想只在需要的时候加载这个很棒的脚本是说
如果浏览器不是Opera。
感谢您的回复。
R ?? mi。
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.
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/
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
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.
这篇关于每个浏览器的脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!