Help!

add an option on a web page to be able to turn music on or..

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Programming RSS
Next:  All Tips  
Author Message
islandjohnny
External


Since: May 17, 2007
Posts: 1



PostPosted: Thu May 17, 2007 4:12 pm    Post subject: add an option on a web page to be able to turn music on or off
Archived from groups: microsoft>public>frontpage>programming (more info?)

I saw a web site that with a click of the mouse on a graphic, it either
turned on background music, or turned it off. I was wondering if Frontpage
2003 offered that feature and if do, how?
Back to top
Trevor Lawrence
External


Since: May 22, 2007
Posts: 74



PostPosted: Fri May 18, 2007 11:27 am    Post subject: Re: add an option on a web page to be able to turn music on or off [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"islandjohnny" <islandjohnny DeleteThis @discussions.microsoft.com> wrote in message
news:0FDC774E-3329-4ED4-B83D-373EC352A25C@microsoft.com...
>I saw a web site that with a click of the mouse on a graphic, it either
> turned on background music, or turned it off. I was wondering if Frontpage
> 2003 offered that feature and if do, how?

FrontPage itself does not, but here is some simple code to do it

Insert this code, using Code or HTML view, where you want the button:
<span id="sound"></span>
<input type="button" value="Play/Stop Music"
onclick="playSound('audio/minuet.mid')"/>

Insert this JavaScript, using Code or HTML view, between <head> and
</head>:
<script type="text/javascript">
function playSound(fname)
{
var x = document.getElementById("sound")
x.innerHTML = (!x.innerHTML ) ? '<embed src="' + fname + '" loop=false
autostart=true hidden>' : ''
}
</script>

The function will play or stop the music on alternate clicks.

Notes:
1. Change the name of the file in "playSound('audio/minuet.mid')" to your
file
2. Some of the quotes are single and some are double. Just cut and paste the
code above to get it right.
----
Trevor Lawrence
Canberra
Microsoft MVP - FrontPage
MVP Web Site http://trevorl.mvps.org
Back to top
Tim Downie
External


Since: Mar 29, 2007
Posts: 9



PostPosted: Fri May 18, 2007 12:45 pm    Post subject: Re: add an option on a web page to be able to turn music on or off [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

islandjohnny wrote:
> I saw a web site that with a click of the mouse on a graphic, it
> either turned on background music, or turned it off. I was wondering
> if Frontpage 2003 offered that feature and if do, how?

How about doing everyone a favour and *resisting* the temptation to have
background music? Wink

Easily the most irritating feature a web site can have.

Tim
Back to top
bgh
External


Since: Mar 11, 2009
Posts: 1



PostPosted: Wed Mar 11, 2009 9:43 am    Post subject: Re: add an option on a web page to be able to turn music on or off [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi, Thanks so much for this help. When I use your code, it gives me a
runtime error of: Line 38 Unterminated String Constant

Here is my actual code and I put (line 3Cool out to the right in parentheses.
Do you see the mistake I've made? I don't. Your help is so appreciated!!



<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<meta http-equiv="Content-Language" content="en-us" />
<title>Database Interface</title>
<bgsound src="Music/Alone.wma" loop="-1">
</head>

<body bgcolor="#ffffff">

<p><b><font size="+3" color="#000080">Database Interface</font></b></p>
<p><a href="Sample_interface/Customers/results_page.asp"
target="_top">Results Page</a><br />
A page that extracts its content from your database.</p>
<p>
<a href="Sample_interface/Customers/editor/submission_form.asp"
target="_top">Submission
Form</a><br />
A form that will insert its results into your database.</p>
<p>
<a href="Sample_interface/Customers/editor/database_editor.asp"
target="_top">Database
Editor</a><br />
A set of web pages that allow you to view, add, delete and update records in
your
database using a web browser.</p>

</body>

</html>

<span id="sound"></span>
<input type="button" value="Play/Stop
Music"
onclick="playSound('Alone.wma')">

<head><script type="text/javascript">
function playSound(fname)
{
var x = document.getElementById("sound")
x.innerHTML = (!x.innerHTML ) ? '<embed src="' + fname + '" loop=false
autostart=true hidden>' : '' (line 3Cool
}
</script>
</head>





--
bgh


"Trevor Lawrence" wrote:

> "islandjohnny" <islandjohnny.DeleteThis@discussions.microsoft.com> wrote in message
> news:0FDC774E-3329-4ED4-B83D-373EC352A25C@microsoft.com...
> >I saw a web site that with a click of the mouse on a graphic, it either
> > turned on background music, or turned it off. I was wondering if Frontpage
> > 2003 offered that feature and if do, how?
>
> FrontPage itself does not, but here is some simple code to do it
>
> Insert this code, using Code or HTML view, where you want the button:
> <span id="sound"></span>
> <input type="button" value="Play/Stop
Music"
> onclick="playSound('audio/minuet.mid')"/>
>
> Insert this JavaScript, using Code or HTML view, between <head> and
> </head>:
> <script type="text/javascript">
> function playSound(fname)
> {
> var x = document.getElementById("sound")
> x.innerHTML = (!x.innerHTML ) ? '<embed src="' + fname + '" loop=false
> autostart=true hidden>' : ''
> }
> </script>
>
> The function will play or stop the music on alternate clicks.
>
> Notes:
> 1. Change the name of the file in "playSound('audio/minuet.mid')" to your
> file
> 2. Some of the quotes are single and some are double. Just cut and paste the
> code above to get it right.
> ----
> Trevor Lawrence
> Canberra
> Microsoft MVP - FrontPage
> MVP Web Site http://trevorl.mvps.org
>
>
>
Back to top
Trevor Lawrence
External


Since: May 22, 2007
Posts: 74



PostPosted: Fri Mar 13, 2009 12:10 am    Post subject: Re: add an option on a web page to be able to turn music on or off [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Well, the code after </html> belongs partly in the <head> section and partly
in the <body> section

Re error in line 38.
This line is split when posted, but I think you had
fname + '" loop=false
when you should have had
fname + "' loop=false

This is very difficult to pick up. The first line reads, between + and loop:
single quote then double quote
which is incorrect

The corrected line reads:
double quote then single quote.

Try this (by cutting and pasting the code)


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<meta http-equiv="Content-Language" content="en-us" />
<title>Database Interface</title>

<script type="text/javascript">
function playSound(fname)
{
var x = document.getElementById("sound")
x.innerHTML = (!x.innerHTML )
? '<embed src="' + fname + '"'
/* "' is double then single^ ^ '"' is single then double
then single */
+ ' loop=false autostart=true hidden>'
: ''
/* ^ '' is two singles */
}
</script>
</head>

<body bgcolor="#ffffff">
<span id="sound"></span>
<input type="button" value="Play/Stop Music"
onclick="playSound('Alone.wma')">

<!-- Rest of html code -->

</body>
</html>

This worked for me, using a file named 'minuet.mid'. Yours is a .wma file,
but if the player recognises it, it should play OK

--
Trevor Lawrence
Canberra
Web Site http://trevorl.mvps.org
"bgh" <bridget.RemoveThis@haakwine.com> wrote in message
news:8836191F-F288-475F-889C-E939995A4866@microsoft.com...
> Hi, Thanks so much for this help. When I use your code, it gives me a
> runtime error of: Line 38 Unterminated String Constant
>
> Here is my actual code and I put (line 3Cool out to the right in
> parentheses.
> Do you see the mistake I've made? I don't. Your help is so appreciated!!
>
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Programming All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum