Toggling Sound On/Off

G

Guest

I have been adding music to my web pages, but I would like it so the visitor
can toggle the sound on or off. I cannot find a way to do this. Someone
help me please. Steven
 
S

Stefan B Rusynko

1) Make sure the sound files are inserted using a Named Embed tag (usually just before the </body> tag)

<embed src="soundfile.mid" name="theNoise" id="theNoise" autostart="true" loop="true" width="0" height="0" hidden align="center">

2) Insert a link to turn the sound off

<a href="javascript:killNoise();">No Sound (or insert an image here)</a>

3) Insert this one of these scripts in the HEAD section of each page

FOR FRAMED PAGES USE:
<script language="JavaScript" language="JavaScript"><!-- Hide It:
function killNoise() {
// The Embedded sound is in a framed page (frame is named "TheFrame")
parent.TheFrame.embeds['theNoise'].stop(); return false;
}
// ShowIt: --></script>

FOR UNFRAMED PAGES USE:
<script language="JavaScript" language="JavaScript"><!-- Hide It:
function killNoise() {
// The Embedded sound is in an Unframed Page
document.theNoise.stop();return true;
}
// ShowIt: --></script>


--




|I have been adding music to my web pages, but I would like it so the visitor
| can toggle the sound on or off. I cannot find a way to do this. Someone
| help me please. Steven
 
G

Guest

I appreciate your response...but Im still at a loss. I have never had to add
any code manually...at least I have been lucky enough that I havent had
to....until now. I want to use mp3 music files, not midi, if that makes a
difference. Maybe I could send a copy of my first webpage code, so you can
show me where I need to insert this. (e-mail address removed). Thanks again
 
G

Guest

I went ahead and tried it as you stated...This is how it looks
<embed src="Let%20Your%20Love%20Flow.mp3" name="theNoise" id="theNoise"
autostart="true" loop="true" width="0" height="0" hidden align="center">
<a href="javascript:killNoise();">No Sound </a>
</head>
<script language="JavaScript" language="javascript"><!--Hide It: function
killnoise() {script>
//The Embedded sound is in a framed page (frame is named "TheFrame")
parent.TheFrame.embeds['thenoise'].stop(); return false;
}
// ShowIt: --></script>

However, when I preview it I get a script error message that states line 25
char 44..."return" statement outside of function...referring to }

I was amazed to see that when I go to preview that my No Sound link is
there, but when I click on it...I also get another script error message
saying Line 1 Char 1...
object expected. This is how my Line 1 reads

<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:blush:="urn:schemas-microsoft-com:blush:ffice:blush:ffice"
xmlns="http://www.w3.org/TR/REC-html40">

There is no sound, and each time I return my embed src line is highlighted.
All that I have did is enter the code as you explained...but when you talk
about using
a Named Embed tag...again Im lost. My sound was entered through the page
properties. Am I missing something. Steven



Stefan B Rusynko said:
1) Make sure the sound files are inserted using a Named Embed tag (usually just before the </body> tag)

<embed src="soundfile.mid" name="theNoise" id="theNoise" autostart="true" loop="true" width="0" height="0" hidden align="center">

2) Insert a link to turn the sound off

<a href="javascript:killNoise();">No Sound (or insert an image here)</a>

3) Insert this one of these scripts in the HEAD section of each page

FOR FRAMED PAGES USE:
<script language="JavaScript" language="JavaScript"><!-- Hide It:
function killNoise() {
// The Embedded sound is in a framed page (frame is named "TheFrame")
parent.TheFrame.embeds['theNoise'].stop(); return false;
}
// ShowIt: --></script>

FOR UNFRAMED PAGES USE:
<script language="JavaScript" language="JavaScript"><!-- Hide It:
function killNoise() {
// The Embedded sound is in an Unframed Page
document.theNoise.stop();return true;
}
// ShowIt: --></script>


--




|I have been adding music to my web pages, but I would like it so the visitor
| can toggle the sound on or off. I cannot find a way to do this. Someone
| help me please. Steven
 
S

Stefan B Rusynko

Post a URL to the page online
The Embed does not go in the HEAD section,
- it goes inside the <BODY> tags before the </body> tag

Only the Correct script from my post (depending on whether you use fames or not) goes in the HEAD section

PS
Remove all spaces from file names
- rename your sound file as
Let_Your_Love_Flow.mp3


--




|I went ahead and tried it as you stated...This is how it looks
| <embed src="Let%20Your%20Love%20Flow.mp3" name="theNoise" id="theNoise"
| autostart="true" loop="true" width="0" height="0" hidden align="center">
| <a href="javascript:killNoise();">No Sound </a>
| </head>
| <script language="JavaScript" language="javascript"><!--Hide It: function
| killnoise() {script>
| //The Embedded sound is in a framed page (frame is named "TheFrame")
| parent.TheFrame.embeds['thenoise'].stop(); return false;
| }
| // ShowIt: --></script>
|
| However, when I preview it I get a script error message that states line 25
| char 44..."return" statement outside of function...referring to }
|
| I was amazed to see that when I go to preview that my No Sound link is
| there, but when I click on it...I also get another script error message
| saying Line 1 Char 1...
| object expected. This is how my Line 1 reads
|
| <html xmlns:v="urn:schemas-microsoft-com:vml"
| xmlns:blush:="urn:schemas-microsoft-com:blush:ffice:blush:ffice"
| xmlns="http://www.w3.org/TR/REC-html40">
|
| There is no sound, and each time I return my embed src line is highlighted.
| All that I have did is enter the code as you explained...but when you talk
| about using
| a Named Embed tag...again Im lost. My sound was entered through the page
| properties. Am I missing something. Steven
|
|
|
| "Stefan B Rusynko" wrote:
|
| > 1) Make sure the sound files are inserted using a Named Embed tag (usually just before the </body> tag)
| >
| > <embed src="soundfile.mid" name="theNoise" id="theNoise" autostart="true" loop="true" width="0" height="0" hidden
align="center">
| >
| > 2) Insert a link to turn the sound off
| >
| > <a href="javascript:killNoise();">No Sound (or insert an image here)</a>
| >
| > 3) Insert this one of these scripts in the HEAD section of each page
| >
| > FOR FRAMED PAGES USE:
| > <script language="JavaScript" language="JavaScript"><!-- Hide It:
| > function killNoise() {
| > // The Embedded sound is in a framed page (frame is named "TheFrame")
| > parent.TheFrame.embeds['theNoise'].stop(); return false;
| > }
| > // ShowIt: --></script>
| >
| > FOR UNFRAMED PAGES USE:
| > <script language="JavaScript" language="JavaScript"><!-- Hide It:
| > function killNoise() {
| > // The Embedded sound is in an Unframed Page
| > document.theNoise.stop();return true;
| > }
| > // ShowIt: --></script>
| >
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| > http://www.net-sites.com/sitebuilder/newsgroups.asp
| > _____________________________________________
| >
| >
| > |I have been adding music to my web pages, but I would like it so the visitor
| > | can toggle the sound on or off. I cannot find a way to do this. Someone
| > | help me please. Steven
| >
| >
| >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top