Solved

Launching a .wav with a mouseclick

Posted on 1997-05-20
2
306 Views
Last Modified: 2012-08-14
Okay, this shouldn't be too difficult. I just need another idea how to do it most effectively.  I need to play a short .wav file when someone clicks on a link (this is an image, and I will be using 'onclick= ...'  but I don't want to have it open a new window every time. Should I create a frame with a size of 0,0 and target the .wav there?  Or is there a way to make it play without bringin' up a new window. I was hoping for something like "onclick=PlaySound("soundfile.wav");return true;"
Any suggestions? I'll make this one 100 points, as I am anxious for a response, and I was hoping for a really clean method that would work on netscape and explorer both. :)
0
Comment
Question by:jvoisin
2 Comments
 
LVL 5

Accepted Solution

by:
Trevor013097 earned 100 total points
ID: 1265614
Okay try this:-

<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<SCRIPT LANGUAGE="JavaScript">
function start()
{
document.the-name.play(false);
}
</SCRIPT>


<BODY>

<EMBED SRC="filename.wav" HIDDEN=TRUE AUTOSTART=FALSE NAME="the-name" MASTERSOUND>

<a href="JavaScript:start();">Start Music</A>

</BODY>

</HTML>


This simply changes the play property of the embedded sound when you click on the link.
0
 

Author Comment

by:jvoisin
ID: 1265615
But, if you try this with Internet Exploder, you will get 'Object dosen't support this property or method' I was hoping for a method that works with both Netscape and MSIE..

(BTW I did it with MSIE 3.02 and 4.0 both are a no-go)

....
function start(){document.BING.play(false);}</SCRIPT>
<BODY>
....
<EMBED SRC="bing.wav" HIDDEN=TRUE AUTOSTART=FALSE NAME="BING" MASTERSOUND>
....
<a href="javascript:parent.frames[1].history.go(-1)"
  onmouseover="ImgFunc('button1','button1n');showInfo('Go Back One Page');return true;"
  onmouseout="ImgFunc('button1','button1');clearInfo();return true;"
  onclick="start();return true;"
  target ="MD_Page">
...


Everything works awesome in Netscape though, and I think that's 70% or more...

I'll just make it so that the script won't run with exploder.

Thanks alot..  If you think of another way that explorer won't choke on, let me know.  :)

Awesome speed on the answer BTW, less than an hour, I bet the newsgroups would have taken a week at least.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question