Need some help with a Javascript

M

Mr B

I do not normally cross post, however, I posted my question in the General
Questions area and did not get any help so I thought I would try this one.

I am not sure that this is the place to ask the question, but here goes
anyway:

I have a page that has an audio file that the visitor can play or shut off.

I also have a hyperlink that opens another page in a new window. This page
has also has an audio file, but this one starts when the page loads.

It is possible that the visitor has started the audio on the first page and
then click the link to open the second page. If this happens, both audio
files are then playing.

What I need is a solution that will stop the audio from the first page when
the visitor clicks the hyperlink on the first page to open the second page.

Any suggestions will be appreciated.

Mr B
 
K

Kevin Spencer

Hi Mr B,

If I understand you correctly, you already have a JavaScript that can both
start and stop the player on the first page. So, what you need to do is to
create a JavaScript hyperlink to the second page, something along the lines
of the following (pseudo-code):

<script type="text/javascript><!--
function openAudioWindow(strURL)
{
player.stopPlaying();
window.open(strURL, ...);
}
// --></script>

<a href="javascript:eek:penAudioWindow('sompage.html');">Click here to open
other window</a>

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Everybody picks their nose,
But some people are better at hiding it.
 
M

Mr B

Kevin,

Thanks for the reply.

Actually when I posted this, I did not have any javascripts. However, since
that, a friend of mine put me on to a possible solution. I have now written
my first javascript function and even implemented using a variable and
managed to get the job done.

The learning curve never stops. Does it? :)

What I actually needed to do was to stop the audio that was running and open
a specific html document in a new window on the same event.

Thanks for the input.

Mr B
 
K

Kevin Spencer

What I actually needed to do was to stop the audio that was running and
open
a specific html document in a new window on the same event.

That was what my pseudo-code illustrated. As I don't know what sort of
device youy're using to manipulate the audio, I put in a line which read:

player.stopPlaying();

This would be replaced with the actual code to stop the audio. The next line
would be replaced with the window.open() implementation you choose for
yourself.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Everybody picks their nose,
But some people are better at hiding 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

Top