开发者

I need help creating a javascript popup on page load that closes when the parent window closes

开发者 https://www.devze.com 2023-03-27 09:41 出处:网络
First off, thanks for taking the time to check this out and provide assistance. This is a fantastic community.

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消