SharePoint 2010 User Control Mouseover JavaScript Sound RRS feed

  • Question

  • I have created a user control for SharePoint 2010. One of the requirements is to play a sound file on mouseover. I have a simple Javascript solution which works in a standard ASP.NET application, but is giving me trouble in SharePoint. The relevant .ascx looks like this:

    <div id="divMouse" onmouseover="playclip();" onmouseout="stopclip();">



    <div id="divSound">
        <bgsound id="sound" loop="false" />

    The JavaScript itself is so:

    function playclip() {
                document.all['divSound'].src = "/_controltemplates/MyNamespace/MySoundFile.mp3";

    Mousing over the div in SharePoint results in the first second or so of the file playing repeatedly, as long as the pointer is in the div. When I place an alert after the above line in the mouseover event, it gets more interesting - if the alert box is left open, the sound file plays to completion. If it is closed, the sound stops instantly - the pointer has to leave the div to click the 'OK' button on the alert box, and the stopclip() code has also been shown to be executing with a second alert box.

    I would appreciate anyone's thougts on this, as I am out of ideas, and haven't been able to turn up anything that helps.

    Echo Train Nashville TN

    • Edited by Echo Train Tuesday, September 10, 2013 7:54 PM
    Tuesday, September 10, 2013 7:52 PM


  • It turns out that an AJAX component of the control which updates from a web service was the problem. Whenever the source data is updated, the control is updated, which is as often as once per second at peak. The update apparently resets the mouseover event. Coincidentally, my test with an ASP.NET application was at a time when the web service was less active, so the effect was not in evidence.

    My solution was to parcel the control into two divs, with the static one handling the mouseover. I used a little :hover CSS to show the user where the mouseover portion is.

    Echo Train Nashville TN

    • Proposed as answer by Christopher Brotsos Thursday, September 12, 2013 4:19 PM
    • Marked as answer by Echo Train Thursday, September 12, 2013 7:33 PM
    • Unmarked as answer by Echo Train Thursday, September 12, 2013 7:34 PM
    • Marked as answer by Echo Train Friday, September 13, 2013 3:22 AM
    • Edited by Echo Train Friday, September 13, 2013 3:23 AM
    Thursday, September 12, 2013 2:51 PM