Women in Technology

Hear us Roar



Article:
  Build a Simple MP3 Player for Your Site
Subject:   Some users double-click on links ...
Date:   2006-10-08 22:32:10
From:   gracion
...which results in the two windows opening for the same MP3 and both playing at once, out of sync! By enabling the window staggering code, at least there's an on-screen clue that two files are playing.


I'd like to prevent this and only allow one window to open per MP3 (I have several MP3's linked from one page). One way would be to add an associative array (dictionary? I forget what we call them in JavaScript), of all the windows keyed by HREF URL. The second click (which could also occur later) brings the correct player window to the front.


Or maybe there's a double-click detection attribute in JavaScript. Anybody care to suggest a solution?

Full Threads Oldest First

Showing messages 1 through 3 of 3.

  • Some users double-click on links ...
    2006-10-18 15:18:36  cwiggins418 [View]

    I really like this script, however I have a poblem I hope I can get some help with. When I click on one song link it is opening the popup window and a full new window. I am getting both. I would also like to have only one window pop up at a time for multiple links on the page. I took out the uniqueId line but that didn't work. Can anyone help
    • David Battino photo Preventing Redundant Windows
      2006-10-23 12:18:23  David Battino | O'Reilly Blogger [View]

      If you’re getting both a normal window and a pop-up when you click the link, it probably means you’ve omitted the return false part of the link. It’s designed to make the browser fire only the JavaScript section of the link, not the href= section. (The href section should fire only when JavaScript is disabled.)
  • David Battino photo Some users double-click on links ...
    2006-10-09 01:16:05  David Battino | O'Reilly Blogger [View]

    You could use one ID for all links (so you'd have only one pop-up window ever) or give each link its own ID (so you'd have only one pop-up per link).

    To do the former, remove the UniqueID = UniqueID + 1 line. To do the latter, add another attribute to the link, as in my follow-up article, "Build a Better Web Audio Player" (http://digitalmedia.oreilly.com/2006/05/31/build-a-better-web-audio-player.html).