I need help creating a javascript popup on page load that closes when the parent window closes
First off, thanks for taking the time to check this out and provide assistance. This is a fantastic community.
Alright to my question...I need to create a popup that contains a music player when a site is loaded. Once the site is closed, it should close the popup window. This so far is some coe ive come up with, however I'm not that great at javascript. Right now I'm just trying to build the open close actions. I'll add the player later.
<script language="JavaScript">
function load() {
window.open('http://www.google.com','player','
height='320,width=320,scr开发者_如何学运维ollbars,resizable');
}
function unload() {
parent.player.close();
}
window.onload = load;
window.onunload = unload;
</script>
This code does not work. I'm not sure why. What do I have to modify to make it function correctly?
<script language="JavaScript">
var player;
function load() {
player = window.open('http://www.google.com','player','height=320,width=320,scrollbars,resizable');
}
function unload() {
player.close();
}
window.onload = load;
window.onunload = unload;
</script>
精彩评论