如何在Firefox中播放声音? [英] How to play a sound in Firefox?

查看:90
本文介绍了如何在Firefox中播放声音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,


我发现下面的代码添加在:
http://simplythebest.net/sounds/sound_guide.html


不幸的是,代码似乎无法正常工作在Firefox中。这些是我在Javascript控制台中可以看到的

错误消息:

错误:self.document.guitar.IsReady不是函数

错误:self.document.guitar.stop不是函数


我们还有其他函数需要为FireFox调用吗?任何帮助将

赞赏!


亲切的问候,

Dobedani


< BGSOUND id = BGSOUND_ID src ="">

< bgsound id =" bgsound_id" loop = 1 src =" jsilence.mid">

< embed name =" guitar" SRC =" malaguena.mid" loop = false autostart = false

hidden = true mastersound>


< script language =" JavaScript">

<! -

ver = parseInt(navigator.appVersion)

ie4 =(ver> 3&& navigator.appName!=" Netscape")? 1:0

ns4 =(ver> 3&& navigator.appName ==" Netscape")?1:0

ns3 =(ver == 3 && navigator.appName ==" Netscape")?1:0

function playSound(){

if(ie4)document.all [''BGSOUND_ID'']。src =''malaguena.mid'';

if((ns4 || ns3)

&& navigator.javaEnabled( )

&& navigator.mimeTypes [''audio / x-midi'']

&& self.document.guitar.IsReady()



{

self.document.guitar.play()

}

}


函数stopSound(){

if(ie4)document.all [''BGSOUND_ID'']。src =''jsilence.mid'' ;

if((ns4 | | ns3)

&& navigator.javaEnabled()

&& navigator.mimeTypes [''audio / x-midi'']



{

self.document.guitar.stop()< br $>
}

}

// - >

< / script>


< form name = myform>

< input type = button value =" Play Sound" onClick =" playSound()">

< input type = button value =" Stop Sound" onClick =" stopSound()">

< / form>

Dear All,

I found the code added below at:
http://simplythebest.net/sounds/sound_guide.html

Unfortunately, the code doesn''t seem to work in Firefox. These are the
error messages I can see in my Javascript Console:
Error: self.document.guitar.IsReady is not a function
Error: self.document.guitar.stop is not a function

Are there other functions we have to invoke for FireFox? Any help will
be appreciated!

Kind regards,
Dobedani

<BGSOUND id=BGSOUND_ID src="">
<bgsound id="bgsound_id" loop=1 src="jsilence.mid">
<embed name="guitar" src="malaguena.mid" loop=false autostart=false
hidden=true mastersound>

<script language="JavaScript">
<!--
ver=parseInt(navigator.appVersion)
ie4=(ver>3 && navigator.appName!="Netscape")?1:0
ns4=(ver>3 && navigator.appName=="Netscape")?1:0
ns3=(ver==3 && navigator.appName=="Netscape")?1:0

function playSound() {
if (ie4) document.all[''BGSOUND_ID''].src=''malaguena.mid'';
if ((ns4||ns3)
&& navigator.javaEnabled()
&& navigator.mimeTypes[''audio/x-midi'']
&& self.document.guitar.IsReady()
)
{
self.document.guitar.play()
}
}

function stopSound() {
if (ie4) document.all[''BGSOUND_ID''].src=''jsilence.mid'';
if ((ns4||ns3)
&& navigator.javaEnabled()
&& navigator.mimeTypes[''audio/x-midi'']
)
{
self.document.guitar.stop()
}
}
//-->
</script>

<form name=myform>
<input type=button value="Play Sound" onClick="playSound()">
<input type=button value="Stop Sound" onClick="stopSound()">
</form>

推荐答案

Dobedani在5/26/2006上午5:57发表以下内容:
Dobedani said the following on 5/26/2006 5:57 AM:
亲爱的所有人,

我发现下面的代码添加在:
http://simplythebest.net/sounds/sound_guide.html

不幸的是,代码似乎在Firefox中不起作用。这些是我在Javascript控制台中可以看到的错误消息:
错误:self.document.guitar.IsReady不是函数
错误:self.document.guitar.stop不是功能

我们还要为FireFox调用其他功能吗?任何帮助将不胜感激!
Dear All,

I found the code added below at:
http://simplythebest.net/sounds/sound_guide.html

Unfortunately, the code doesn''t seem to work in Firefox. These are the
error messages I can see in my Javascript Console:
Error: self.document.guitar.IsReady is not a function
Error: self.document.guitar.stop is not a function

Are there other functions we have to invoke for FireFox? Any help will
be appreciated!




关于该代码的最佳帮助:


查找另一个脚本。在打猎的时候,如果你看到一个关于navigator.appName的任何内容,请跳过它并继续打猎。


-

Randy

comp.lang.javascript常见问题 - http://jibbering.com / faq &新闻组每周

Javascript最佳实践 - http://www.JavascriptToolbox .com / bestpractices /



Best help with regards to that code:

Find another script. When hunting, if you see one that says anything
about navigator.appName, skip it and keep hunting.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/




Dobedani写道:

Dobedani wrote:
亲爱的所有人,

我在下面找到了以下代码:
http:// simplythebest.net/sounds/sound_guide.html

不幸的是,代码似乎在Firefox中不起作用。这些是我在Javascript控制台中可以看到的错误消息:
错误:self.document.guitar.IsReady不是函数
错误:self.document.guitar.stop不是功能

我们还要为FireFox调用其他功能吗?任何帮助将不胜感激!

亲切的问候,
Dobedani

< BGSOUND id = BGSOUND_ID src ="">
< bgsound id =" bgsound_id" loop = 1 src =" jsilence.mid">
< embed name =" guitar" SRC =" malaguena.mid" loop = false autostart = false
hidden = true mastersound>

< script language =" JavaScript">
<! -
ver = parseInt (navigator.appVersion)
ie4 =(ver> 3&& navigator.appName!=" Netscape")?1:0
ns4 =(ver> 3&& navigator.appName ==" Netscape")?1:0
ns3 =(ver == 3&& navigator.appName ==" Netscape")?1:0

功能播放声音(){
if(ie4)document.all [''BGSOUND_ID'']。src =''malaguena.mid'';
if((ns4 || ns3)
& & navigator.javaEnabled()
&& navigator.mimeTypes [''audio / x-midi'']
&& self.document.guitar.IsReady()

{
self.document.guitar.play()
}

函数stopSound(){
if(ie4) document.all [''BGSOUND_ID'']。src =''jsilence.mid'';
if((ns4 || ns3)
&& navigator.javaEnabled()
&& navigator.mimeTypes [' audio / x-midi'']

{
self.document.guitar.stop()
}
}
// - > ;
< / script>
< form name = myform>
< input type = button value =" Play Sound" onClick =" playSound()">
< input type = button value =" Stop Sound" onClick =" stopSound()">
< / form>
Dear All,

I found the code added below at:
http://simplythebest.net/sounds/sound_guide.html

Unfortunately, the code doesn''t seem to work in Firefox. These are the
error messages I can see in my Javascript Console:
Error: self.document.guitar.IsReady is not a function
Error: self.document.guitar.stop is not a function

Are there other functions we have to invoke for FireFox? Any help will
be appreciated!

Kind regards,
Dobedani

<BGSOUND id=BGSOUND_ID src="">
<bgsound id="bgsound_id" loop=1 src="jsilence.mid">
<embed name="guitar" src="malaguena.mid" loop=false autostart=false
hidden=true mastersound>

<script language="JavaScript">
<!--
ver=parseInt(navigator.appVersion)
ie4=(ver>3 && navigator.appName!="Netscape")?1:0
ns4=(ver>3 && navigator.appName=="Netscape")?1:0
ns3=(ver==3 && navigator.appName=="Netscape")?1:0

function playSound() {
if (ie4) document.all[''BGSOUND_ID''].src=''malaguena.mid'';
if ((ns4||ns3)
&& navigator.javaEnabled()
&& navigator.mimeTypes[''audio/x-midi'']
&& self.document.guitar.IsReady()
)
{
self.document.guitar.play()
}
}

function stopSound() {
if (ie4) document.all[''BGSOUND_ID''].src=''jsilence.mid'';
if ((ns4||ns3)
&& navigator.javaEnabled()
&& navigator.mimeTypes[''audio/x-midi'']
)
{
self.document.guitar.stop()
}
}
//-->
</script>

<form name=myform>
<input type=button value="Play Sound" onClick="playSound()">
<input type=button value="Stop Sound" onClick="stopSound()">
</form>




上面的代码应该在几年前退役了。对于旧式的Netscape浏览器而不是现代的Mozilla系列,只需要
测试

浏览器,例如最近的Netscape,Mozilla和Firefox。因此Firefox

被锁定。在浏览器大战的早期,Netscape将支持嵌入声音,而IE将支持bgsound。然而IE很快支持嵌入bgsound,但Netscape和现代Mozilla家族

浏览器从不支持bgsound。这些天你通常只需使用一个嵌入

代码而无需测试浏览器类型,因为现在IE浏览器早于4的
已经全部消失了,这是一件好事,因为很多现金浏览器设置为欺骗其他浏览器以避免因浏览器类型检测错误导致的锁定

。然而嵌入从来没有

是html的官方部分,还有更多现代的方法可以获得包括声音在内的



Javascript已经存在了很长时间了,随着时间的推移计算。

有许多网站都有脚本的例子,而且还没有更新大概10美元年份。其中一些脚本在现代浏览器上无法正常工作。由于网页没有官方质量控制

,任何人都可以提供任何东西并保留在那里

没有更新,只要他们为服务器支付主机费用空间。这个

尤其适用于许多人提交的剧本集合,

经常在遥远的过去。



The above code should have been retired several years ago. It only
tests for old style Netscape browsers and not modern Mozilla family
browsers such as recent Netscape, Mozilla, and Firefox. Hence Firefox
is locked out. In the early days of the browser wars, Netscape would
support embed for sound and IE would support bgsound. However IE soon
supported embed for bgsound, but Netscape and modern Mozilla family
browsers never supported bgsound. You can usually just use an embed
code these days without testing for browser type, as IE browsers
earlier than 4 now are all but gone, which is a good thing because many
modern browsers are set to spoof other browsers to avoid lockouts
resulting from faulty browser type detection. However embed never has
been an official part of html, and there are more modern methods for
including sound on a page.

Javascript has been around a long time now, as time goes for computing.
There are many sites around with examples of script that have not been
updated for perhaps 10 years. Some of these scripts do not work
properly on modern browsers. Since there is no official quality control
for web pages, anyone can put up just about anything and keep it there
without updates, so long as they pay their host for server space. This
is especially true for collections of script submitted by many people,
often in the distant past.



Dobedani写道:

Dobedani wrote:
亲爱的,

我发现下面的代码添加在:
http://simplythebest.net/sounds/sound_guide.html
不幸的是,代码似乎无法在Firefox中运行。
Dear All,

I found the code added below at:
http://simplythebest.net/sounds/sound_guide.html

Unfortunately, the code doesn''t seem to work in Firefox.




尝试此演示并使用代码,如果您认为它没问题。它并没有被广泛测试,所以我不保证任何东西:

http://www.hotspot.freeserve.co.uk/ttdemo/



Try this demo and use the code if you think it''s OK. It''s not widely
tested so I''m not guaranteeing anything:

http://www.hotspot.freeserve.co.uk/ttdemo/

这篇关于如何在Firefox中播放声音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆