Hello!

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

CODE
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:

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


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

 

 

 


Reply