PDA

View Full Version : how to get bg music to continue playing



joycie
08-06-2006, 11:26 AM
On the main webpage, I use the following javascript to create a link to the popup window of a sub webpage.

<a href="javascript://" onClick="window.open('http://filename.htm','','menubar=no,status=no,scrollbars=no,top=200,left=200,toolbar=no,width=800,height=600')">

The main webpage has embedded background music. When I click on the link to open the popup sub webpage, the background music of the main webpage stopped. How can I let the music of the main webpage to continue even if the sub webpage is opened?

The code I use for the embedded music is :
<EMBED src=music.wma hidden=true LOOP="true"
AUTOSTART="TRUE">

Any help would be appreciated. Thanking in advance.

boogyman
08-06-2006, 08:29 PM
<embed src="file.wma" loop="1" autostart="1" hidden="1" \>

joycie
08-07-2006, 02:11 AM
Thanks Pissa, but the music still stop when I click to open the subpage.

mburt
08-07-2006, 02:13 AM
Could you provide a link to the site where the problem is occuring?

blm126
08-07-2006, 04:10 AM
<a href="javascript://" onClick="window.open('http://filename.htm','','menubar=no,status=no,scrollbars=no,top=200,left=200,toolbar=no,width=800,height=600')">

Don't do that. The javascript:// part is the problem. Here's an untested solution.


<a href="#" onClick="function(){window.open('http://filename.htm','','menubar=no,status=no,scrollbars=no,top=200,left=200,toolbar=no,width=800,height=600');return false;}">

joycie
08-07-2006, 12:41 PM
Thanks to mburt, especially blm126 for providing the script.

It worked when I removed "function(){" and ";return false;}" ,ie:

<a href="#" onclick="window.open('http://filename.htm','','menubar=no,status=no,scrollbars=no,top=200,left=200,toolbar=no,width=800,height=600')">

blm126
08-07-2006, 03:28 PM
The return false part is important. Here's a better way to do it.
Put this in the < head> tag


<script type="text/javascript">
function openWindow(file){
window.open(file,'','menubar=no,status=no,scrollbars=no,top=200,left=200,toolbar=no,width=800,height=600')
return false;
}
</script>

Then your link


<a href="#" onclick="openWindow('http://somefile.com')">Link</a>

mburt
08-07-2006, 03:38 PM
When you use a blank bookmark (#) I think that would stop the music too. But it may not, so ignore me if I'm wrong :)

blm126
08-07-2006, 03:56 PM
Well it's called an anchor. And since anchors only redirect within the page, the browser should continue to play the music. And then with the return false part the browser does nothing.

mburt
08-07-2006, 04:18 PM
Anchors bring IE users to the top of the page, magically making a bookmark there, which may stop the music.

blm126
08-07-2006, 04:34 PM
Yes, that is why the return false part is important. Also they only take users to the top of the page if you don't include something after(ex. #foo)

mburt
08-08-2006, 03:09 AM
Yeah, #foo doesn't exist so logically the browser won't respond. That's clever :)

joycie
08-08-2006, 03:14 AM
The return false part is important. Here's a better way to do it.
Put this in the < head> tag


<script type="text/javascript">
function openWindow(file){
window.open(file,'','menubar=no,status=no,scrollbars=no,top=200,left=200,toolbar=no,width=800,height=600')
return false;
}
</script>

Then your link


<a href="#" onclick="openWindow('http://somefile.com')">Link</a>


May I know what is the difference if the script is used without the "return false" part?
I use <a href="#" onclick="window.open(filename.htm','','menubar=no,status=no,scrollbars=no,top=200,left=200,toolbar=no,width=800,height=600')"> , when I click on the link, the music of the mainpage did not stop and the subpage opened without any problem.

I need to specify the height of the page for every link because they are of different heights for different sub-webpage.

blm126
08-08-2006, 04:07 AM
Without the return false part, in IE the page will jump to the top. It is not necessary but a good idea.

joycie
08-08-2006, 04:16 AM
Thanks a lot. I understand now.:p