Jump to content
xisto Community

Opera Browser + Javascript + Embeded Sound Embeded sound works in IE, but not in Opera

Recommended Posts

Hello!Here is the problem. There is an Embed object, created like this:

    function createWMPEmbedMarkup(src, id, baseurl) {        // For choice, using the DOM instead of a string         // so the caller gets a node. (Its childNode could be used if you don't want the whole p element)        // Then, if markup is needed instead, innerHTML is available.        var x = document.createElement("embed");        x.setAttribute("FileName", src);        x.setAttribute("type", "application/x-mplayer2");		x.setAttribute("AutoStart", "0");		x.setAttribute("id", id);		x.setAttribute("hidden", "true");        if (!baseurl) {        // Create a raw, backslashed windows path. The plugin is too old to understand file URIs correctly.        // You can do the conversion using the methods you want. This is just an example.            if (document.location.protocol == "file:") {                var loc = decodeURIComponent(document.location.toString().replace(/file:\/\/localhost\//i, "file:///").replace(/file:\/\/\//i, "").replace(/file:\/\//i, "").replace(/\//g, '\\'));                loc = loc.substring(0, loc.lastIndexOf('\\') + 1);                if (loc.charAt(1) != ':' && loc.indexOf("\\\\") != 0) {                    loc = "\\\\" + loc;                }                x.setAttribute("BaseURL", loc);            }        } else {            // If the caller specified a base url, use it.            x.setAttribute("BaseURL", baseurl);        }        var p = document.createElement("p"); // wrap the node in an element so innerHTML can be used. (only Opera has outerHTML)        p.appendChild(x);        return p;    }    // Using document.write for IE's sake. These would go in their own script element somewhere in the page.    document.write(createWMPEmbedMarkup("nos.wav", "sound1").innerHTML);

Now, I want to play this sound file, when user clicks on some image (not when the page is loading - Autostart attrib should be 0)I do it like this:

function MouseClickHandler(){document.getElementById('sound1').play();}

This works ok in IE, but does not react at all in Opera.What can be the problem?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.