Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Opera Browser + Javascript + Embeded Sound, Embeded sound works in IE, but not in Opera
lez77
post May 4 2007, 07:54 AM
Post #1


Newbie
*

Group: Members
Posts: 9
Joined: 2-May 07
Member No.: 42,507



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?
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Javascript Slideshow Tutorial(4)
  2. [help] Java Script: Window.open(10)
  3. Javascript Close Window(15)
  4. One Click Copy And Paste To Clipboard(5)
  5. Adding Rows & Columns In Html Table Using Javascript(1)
  6. Maintaining Browser Size On Your Computer(4)
  7. I'm Making My Own Javascript Only Rpg :d(7)
  8. What Is Json? ,how It Works?(4)
  9. What's The Relationship Between Javascript And Java(5)
  10. Javascript : No Right Click Script !@(12)
  11. Hiding <div> Boxes With Javascript(8)
  12. How Do You Make A Javascript Calculator?(11)
  13. Web Applications: J2ee Or Javascript/css/html(1)
  14. Javascript - What's Your Browser?(3)
  15. Javascript Events Not Working For Ie(6)
  1. Lightbox Js Error In Opera(2)
  2. I`m New To Javascript.(5)
  3. Special Wii Javascript(2)
  4. Simple Firefox Vs. Ie Script Bug; Need A Little Help(3)
  5. Javascript Error(2)
  6. Is It Possible To Create A Web Based Mmo In Javascript?(4)
  7. Capturing Username Of Computer(3)
  8. Javascript Object Node Referencing Help(5)
  9. Flash And Javascript Interaction(1)
  10. Document.write & Noscript Questions (javascript)(1)
  11. Java Vs Javascript(11)
  12. Adjusting Rows/cols Of Frames In Frameset Using Javascript Is Not Working In Firefox 3 Is Not Working(4)
  13. Need Help With Javascript Drag And Drop Script(2)


 



- Lo-Fi Version Time is now: 8th October 2008 - 08:56 AM