Help Please!

F

Franklin P Patchey

I don't know anything about Javascript, but a little about standard HTML.

I have created a website and have set the homepage to automatically play a
sound file on opening.

What I would like is for a random sound file (from my "audio" directory) to
be played instead of the same one each time you visit.

Can this be done and if so can someone please supply me with the (or an
example) of code?.........
 
I

Ivo

Franklin P Patchey said:
I don't know anything about Javascript, but a little about standard HTML.

I have created a website and have set the homepage to automatically play a
sound file on opening.

What I would like is for a random sound file (from my "audio" directory) to
be played instead of the same one each time you visit.

Can this be done and if so can someone please supply me with the (or an
example) of code?.........

Please use descriptive subject lines.
Yes, it can be done. One way would be to put the names of the files in an
array, use Math.random()* the length of the array to randomly select a file,
and document.write or manipulate the DOM to embed it.
To find out more about what an array is etc., read this newsgroup, the
multitude of websites about javascript and ask Google. The more you tell us
about what you have tried, the more specific our help can be.
HTH
Ivo
 
I

Ivo

Franklin P Patchey said:
I don't know anything about Javascript, but a little about standard HTML.

I have created a website and have set the homepage to automatically play a
sound file on opening.

What I would like is for a random sound file (from my "audio" directory) to
be played instead of the same one each time you visit.

Can this be done and if so can someone please supply me with the (or an
example) of code?.........

Please use descriptive subject lines.
Yes, it can be done. One way would be to put the names of the files in an
array, use Math.random()* the length of the array to randomly select a file,
and document.write or manipulate the DOM to embed it.
To find out more about what an array is etc., read this newsgroup, the
multitude of websites about javascript and ask Google. The more you tell us
about what you have tried, the more specific our help can be.
HTH
Ivo
 
D

Dr John Stockton

JRS: In article <[email protected]>, seen in
Franklin P Patchey
I don't know anything about Javascript, but a little about standard HTML.

I have created a website and have set the homepage to automatically play a
sound file on opening.

That will not work on systems which, like mine, have sound switched off.
It will also annoy those who were expecting to be able to brows the web
in peace and quiet, or while listening to their own choice of music.

Sound should only be played when the potential hearer actually wants it.
 

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

Members online

Forum statistics

Threads
474,100
Messages
2,570,635
Members
47,242
Latest member
BarrettMan

Latest Threads

Top