Hi,
I looked around and can't find anything on this at all and can not get
it to work for IE.
I'm trying to loop multiple sounds on a game, with three unique
variables, when a link is clicked. Something like...
<Script Language="JavaS cript">
<!--
function playSound(sound Name, loops, timeLength){
document.embeds[soundName].play();
if(loops > 1){
setTimeout("pla ySound(soundNam e, loops, timeLength)", timeLength); }
} // End function.
//-->
</Script>
<!-- EMBEDED SOUNDS//-->
<embed src="frog.wav" autostart="fals e" loop="false" hidden="true"
name="frog">
<embed src="bird.wav" autostart="fals e" loop="false" hidden="true"
name="bird">
<embed src="rooster.wa v" autostart="fals e" loop="false" hidden="true"
name="rooster">
<!-- LINKS //-->
<a href="javascrip t:playSound('fr og', 3, 4500);">FROG</a>
<a href="javascrip t:playSound('bi rd', 1, 3000);">BIRD</a>
<a href="javascrip t:playSound('ro oster', 2, 7500);">ROOSTER </a>
....errrrr, umm, ...or something like that ;-\
There could be a typo above because I'm just going by memory, (which
hasn't been very good lately). Plus I'm on no sleep for quite a while.
But I "think" it might resemble what I've been trying to do?
There's several sounds on the page.
Each has it's own link and variables,
...name (soundName),
...times it will play (loops),
...and sound length (soundLength).
I have been able to get "something like" above (not exactly like example
above) to work on MSN-TV but not for IE on a pc. I'm not a big fan of
sounds on a webpage but in this situation, a game, we're trying to get
it to work but so far unsuccessfully. So I do know my way around JS a
little bit and sounds almost not at all. This problem has been holding
up this page for a while and am truly using comp.lang.javas cript here as
a last resort! Any help or guidance at all on this would be very much
appreciated, (more than you'd ever know!), thanks!
BTW;
I've lurked here on and off for years, learned a lot, and really prefer
to find out my own answers, to just work it out myself, but this one
really has me stumped :(
Have a good weekend,
Thanks again,
--
-kW- 1 4667
"Knocked Wood" <Kn*********@we btv.net> wrote in message
news:29******** ******@storeful l-2116.public.law son.webtv.net.. .
<snip> <Script Language="JavaS cript">
<script type="text/javascript">
<!--
This "hide from older browsers" stuff is no longer needed. The browsers
that were young when it was introduced are now so old themselves that
they have all gone out of use. function playSound(sound Name, loops, timeLength){ document.embeds[soundName].play();
That is optimistic. You are assuming that - document.embeds[soundName] -
will resolve to an object and that the object will have a - play -
method. You should be testing these things before trying to use them.
Assumptions kill JavaScripts.
if(loops > 1){ setTimeout("pl aySound(soundNa me, loops, timeLength)", timeLength); }
The string provided as the first parameter to setTimeout is evaluated
and executed in the global context and soundName, loops and timeLength
are function parameters so they will be undefined in the global context.
As the values represent a string and two number they can be included in
the setTimeout string as literal:-
setTimeout("pla ySound(\""+soun dName+"\", "+loops+
", "+timeLength+") ", timeLength);
However, you have failed to decrement the - loops - parameter so this
code will loop forever.
} // End function.
//--> </Script>
<!-- EMBEDED SOUNDS//--> <embed src="frog.wav" autostart="fals e" loop="false" hidden="true " name="frog">
<embed src="bird.wav" autostart="fals e" loop="false" hidden="true " name="bird">
IE may be happier if this embed element has an ID attribute instead or
(or as well as) a name, but it is difficult to say as embed is not a
valid HTML 4 element.
<a href="javascrip t:playSound('fr og', 3, 4500);">FROG</a>
<snip>
Never use the javascript: pseudo protocol to execute a JavaScript
function as a side effect. Activating an HREF is considered navigation
by web browsers and if the browser gets the impression that you are
navigating away from the current page all bets are off for any activity
on the current page (the browser thinks you have finished with it). An
onclick attribute that properly cancels the navigation specified in the
HREF is the only safe way of triggering a JavaScript function from a
link.
I have been able to get "something like" above (not exactly like example above) to work on MSN-TV but not for IE on a pc.
No, that - playSound - function would either fail, or if it worked
(given a very faulty ECMA script implementation) it would loop
indefinitely.
I'm not a big fan of sounds on a webpage but in this situation, a game, we're trying to get it to work but so far unsuccessfully. So I do know my way around JS a little bit and sounds almost not at all.
I am not a big fan of sounds on web pages either (largely because I am
always either using my computer to listen to something else and don't
appreciate the intrusion, or I am not listening to anything because
silence is what I want so I still don't appreciate the intrusion) so I
haven't scripted sound playing except for a bit of debugging on this
group.
But you have not defined "not working on IE". Do you get error messages
and if so which? It would be better to post the code that works on
MSN-TV instead of your recollections of it and even better to put a
demonstration test page online (it has to be online as nobody else has
your sound files). A demonstration page does not need to include any
more than the sound playing code.
<snip> BTW; I've lurked here on and off for years, learned a lot, and really prefer to find out my own answers, to just work it out myself, ...
<snip>
And you haven't noticed that way we tell everyone not to use the
javascript : pseudo-protocol? Or did you assume that we do not know what
we are talking about?
Richard. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Marc |
last post by:
Hello,
I have a self - submitting form with multiple submits and I want to
detect after the submit which button is pressed.
Code example:
<form name="example" method="post" action="/test.php">
<input type =submit name="add"> form elements but also
<a href="#" onClick=document.myForm.submit()>edit</a>
|
by: Dave Parrin-Bull |
last post by:
Hi all,
I have been asked (nay told!) to do a quiz for a webpage at work, now
I can do the basic things like getting the radio boxes up there and
assign values to them but here is what they want:
5 options (done that)
You can only select 2 of the 5 options (dont know how to do that)
|
by: grandeandy |
last post by:
question: in the code below, and in general, how would I input multiple
functions into the code, and get multiple outputs? basically, I want to
be able to add say 2 or 3 of the div's to the link so that it shows
multiple div's at once.
<script language="javascript">
<!--
var state = 'none';
function hide(layer_ref) {
|
by: David |
last post by:
Hi everyone,
I am trying to stop an image preload sequence by the click of a mouse but
have been unsuccessful trying several methods. Imagine this simple script
below that loads 50 images to cache. If the stopPreload() function is
activated and the ret val set to false, the preload() function still
continues to the end.
Any suggestions on how to stop the preload() function in its process, what
conditions are necessary?
|
by: Dave Spencer |
last post by:
Hi all,
New to this group and to C# in general (experienced in MFC). Anyway I have
a ListView and a foreach loop that is doing something to each item in the
list and updating the list on the screen. I have a button on the screen
that I'll call STOP that is supposed to stop the processing of the loop in
midstream. I have a bool global variable call bStop. The OnClick for the
stop button sets bStop to true. The loop checks the value...
| |
by: Arnold |
last post by:
Hi there,
Here's the situation--there is a text field in a form in which students
will key in data. On the keypress event, I'd like for different sounds
to be played for each character typed, either randomly or in a loop (I
have a number of small, cool, computer-like sounds). I can get one
sound to play for the keypress event, but don't know how to play
multiple sounds.
Here's the codes for playing one sound...
|
by: bonneylake |
last post by:
Hey Everyone,
Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also the parts section an i seem to be having trouble.
When i try to insert into the parts section i get the error Invalid character value for cast specification. But not sure what i am doing wrong. Here is what i am using to insert. All the sections...
|
by: bonneylake |
last post by:
Hey Everyone,
Well i am not sure if this is more of a coldfusion problem or a javscript problem. So if i asked my question in the wrong section let me know an all move it to the correct place.
what i am trying to display previously entered multiple fields. I am able to get my serial fields to display correctly, but i can not display my parts fields correctly.
Currently this is what it does
serial information 1
parts 1
|
by: Ciary |
last post by:
Hi all,
i've got another problem. it's based on the question i asked before about creating a onclick-property using javascript.
now what i want to do is create multiple divs with an onclick-property using a for-loop and a 2D array.
for(var m = 0; m < inputdivs.length; m++){
var arr = inputdivs;
var newd = document.createElement("div");
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |