473,568 Members | 3,014 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WindowsXP and Javascript to play a sound on a page

On most my pages, I use Javascript to play a sound. It works fine in
Netscape 4.7, Netscape 7.2, Firefox 1.0, IE5 and IE6 using Windows98 as
the operating system. However, using WindowsXP as the operating system,
the entire Netscape 7.2 browser and Firefox 1.0 browser shuts down when
I try to use the Back button on these pages. Is there some setting in
Windows XP that is causing this or is there something I can add to the
Javascript to prevent this from happening?

Here's a sample page - http://keyserfan.home.mindspring.com/millers.htm

Thanks,
Keyser
Jul 23 '05 #1
2 2175


Keyser wrote:
On most my pages, I use Javascript to play a sound. It works fine in
Netscape 4.7, Netscape 7.2, Firefox 1.0, IE5 and IE6 using Windows98 as
the operating system. However, using WindowsXP as the operating system,
the entire Netscape 7.2 browser and Firefox 1.0 browser shuts down when
I try to use the Back button on these pages. Is there some setting in
Windows XP that is causing this or is there something I can add to the
Javascript to prevent this from happening?

Here's a sample page - http://keyserfan.home.mindspring.com/millers.htm


That page doesn't use JavaScript "to play a sound", it simply does a
document.write for an <embed src="somefile.w av"> so that the browser
loads a plugin to play the sound if a plugin is available.
I have tried that page with Windows XP, Firefox 1.0 and the Quicktime
plugin 6.0 set up to play audio/wav files and I have no problems going
to another page and then back to the page.
You haven't told us which plugin you are using.

As for the script in that page it looks as follows (:

<SCRIPT language=JavaSc ript>
<!-- Original: Kipp W. Shinabarger ([snipped email here]) -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
var MSIE=navigator. userAgent.index Of("MSIE");
var NETS=navigator. userAgent.index Of("Netscape") ;
var OPER=navigator. userAgent.index Of("Opera");
if((MSIE>-1) || (OPER>-1)) {
document.write( "<BGSOUND SRC=sounds/rumpus2.wav >");
} else {
document.write( "<EMBED SRC=sounds/rumpus2.wav AUTOSTART=TRUE ");
document.write( "HIDDEN=tru e VOLUME=100");
}
// End -->
</SCRIPT>

so you should clean that up, the closing > for the embed is missing e.g.
you need

document.write( '<EMBED SRC="sounds/rumpus2.wav" AUTOSTART="TRUE " ');
document.write( 'HIDDEN="true" VOLUME="100">') ;

though you might better use a single document.write call e.g.

document.write( '<EMBED SRC="sounds/rumpus2.wav" AUTOSTART="TRUE " ' +
'HIDDEN="true" VOLUME="100">') ;

And all those HTML comments <-- --> have in my view no place inside of a
script element, beside one such comment wrapper around the whole script
code for historical reasons if you want, so you should throw the
comments out respectively use JavaScript comment syntax if you need to
cite where the script comes from e.g.
// This script and many more are available free online at ...

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Thanks for the reply.

I obtained this script from javascript.inte rnet.com many, many years
ago, and I just left in the comments from the original author, mostly to
ensure that he gets the credit for it.

Quicktime is the plug-in called.

I think the issue may be with the security settins in Windows XP on my
PC at work. I recently got a PC with WindowsXP (we've been running
Windows98 also for many years). It only happens at work, not at home,
where I'm still running Windows98. The same thing happens on another
friend's page who uses the same script.

I'll make the changes suggested.

Thanks again,
Keyser
Martin Honnen wrote:


Keyser wrote:
On most my pages, I use Javascript to play a sound. It works fine in
Netscape 4.7, Netscape 7.2, Firefox 1.0, IE5 and IE6 using Windows98
as the operating system. However, using WindowsXP as the operating
system, the entire Netscape 7.2 browser and Firefox 1.0 browser shuts
down when I try to use the Back button on these pages. Is there some
setting in Windows XP that is causing this or is there something I
can add to the Javascript to prevent this from happening?

Here's a sample page - http://keyserfan.home.mindspring.com/millers.htm

That page doesn't use JavaScript "to play a sound", it simply does a
document.write for an <embed src="somefile.w av"> so that the browser
loads a plugin to play the sound if a plugin is available.
I have tried that page with Windows XP, Firefox 1.0 and the Quicktime
plugin 6.0 set up to play audio/wav files and I have no problems going
to another page and then back to the page.
You haven't told us which plugin you are using.

As for the script in that page it looks as follows (:

<SCRIPT language=JavaSc ript>
<!-- Original: Kipp W. Shinabarger ([snipped email here]) -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
var MSIE=navigator. userAgent.index Of("MSIE");
var NETS=navigator. userAgent.index Of("Netscape") ;
var OPER=navigator. userAgent.index Of("Opera");
if((MSIE>-1) || (OPER>-1)) {
document.write( "<BGSOUND SRC=sounds/rumpus2.wav >");
} else {
document.write( "<EMBED SRC=sounds/rumpus2.wav AUTOSTART=TRUE ");
document.write( "HIDDEN=tru e VOLUME=100");
}
// End -->
</SCRIPT>

so you should clean that up, the closing > for the embed is missing
e.g. you need

document.write( '<EMBED SRC="sounds/rumpus2.wav" AUTOSTART="TRUE " ');
document.write( 'HIDDEN="true" VOLUME="100">') ;

though you might better use a single document.write call e.g.

document.write( '<EMBED SRC="sounds/rumpus2.wav" AUTOSTART="TRUE " ' +
'HIDDEN="true" VOLUME="100">') ;

And all those HTML comments <-- --> have in my view no place inside of
a script element, beside one such comment wrapper around the whole
script code for historical reasons if you want, so you should throw
the comments out respectively use JavaScript comment syntax if you
need to cite where the script comes from e.g.
// This script and many more are available free online at ...

Jul 23 '05 #3

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

Similar topics

3
4605
by: Gil | last post by:
I'm trying to write a page that allows me to change the background midi that's playing. I've been going crazy consulting Google Groups, and coming up with ingenious solutions, some of which kind of work in some situations. I'm quite prepared to implement a number of solutions simultaneously and browser-distinguish to select the right one,...
2
7944
by: laredotornado | last post by:
Hello, I had been given this code to play a single sound file embedded in a page. Sadly, the code doesn't actually "play" any sound file. Could you help supply some JS code that will play a sound file for both IE and Mozilla? Thanks, - Dave <html> <head> <title>Make some noize</title>
1
1294
by: cbell | last post by:
I would like javascript file (which can be a .js file) which I can use to play .wav files on demand. there are many pages and there will only be ONE .wav file (about 20 seconds) for each page. the form table to go onto the page will have graphics (not form buttons) for: - play/pause - stop - volume >> I will design the buttons later, the...
1
7990
by: Lam | last post by:
how can I play sound file in a .aspx page written in C#? I try to use the code like the following. But whenI call the play function play("sound.wav", this.SND_ASYNC) my computer give out "be" sound instead playing the file (same code works fine in a windows application written in c# , that mean there is nothing wrong with my sound card.)...
9
3485
by: outstretchedarm | last post by:
How exactly does HTML/Javascript handle playing midi files? Does it have a player imbedded in it? Or does it borrow from the computer's midi player? How could you make a webpage play certain chosen notes via midi? Is there an existing library for such a thing?
3
3289
by: illmagination | last post by:
Hi, I recently received a task to have a .wav file play only once when home page is 1st loaded and only play again when the user re-visits the page by opening a new browser. I am using asp.net 2.0 framework. Could someone please guide me? Thank you.
19
19237
by: Tony | last post by:
I'm working on project that plays movies using Windows Media Player and I'm controlling everything with JavaScript. Per the client I only need to support IE 6 or greater which happens to make things a bit easier. What I need to do is create a playlist and play it using JavaScript. I keep on getting close but not close enough to play the dang...
26
3868
by: Jake Barnes | last post by:
I did a search on the newsgroup comp.lang.javascript. I was searching for "how to play a sound with Javascript". I'm somewhat suprised that the majority of entries are from the 1990s, and there are almost no posts from the last 3 years: ...
8
5201
by: Mateusz Viste | last post by:
Hi, I'm not sure if my question is really related to JavaScript, so please excuse me if that's not the case (and maybe you guys would have an idea what's the cause is and where could I ask)... I recently put the following script online: <script type="text/javascript"><!-- function playmedia(mediafile) { newwindow=window.open(); if...
0
7693
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5501
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.