PDA

View Full Version : onclick/onmouseover in firefox on the mac osx


gvmelle
01-23-2008, 09:39 AM
I have the following code:

<script language="JavaScript"><!--
function EvalSound(soundobj) {
var thissound = eval("document." + soundobj);
thissound.Play();
}//-->
</script>

<embed src="http://weblog.gvmelle.com/images/roffel.mp3" autostart=false hidden=true name="sound1" enablejavascript="true" />

<a href="#" onMouseOver="EvalSound('sound1')">roffel</a>

<img src="http://weblog.gvmelle.com/images/usa.gif" onClick="EvalSound('sound1')">

This is perfectly working under WindowsXP with Firefox 2.0.0.11 an java 1.6.0
but on my Mac OSX 10.5 it works only with Opera en Safari. Not on Firefox nor Camino.

On both OS's I have Quicktime installed.

I get
<embed src="http://weblog.gvmelle.com/images/roffel.mp3" autostart=true hidden=true name="sound1" enablejavascript="true">
working, so It must be either the Eval() function or the onclick/onmouseover that's not compatible.

I tried <script language="JavaScript"><!--
function EvalSound(soundobj) {
var thissound = document.getElementById(soundobj);
thissound.Play();
}
//-->
</script> as function but that gave the same results.

Anyone an idea for a solution?

Kor
01-23-2008, 11:39 AM
Hm...
Try coding in a correct standard way, and give it a try:

- use type, not language

<script type="text/javascript">


- quote all the HTML attributes' values.

<embed src="http://weblog.gvmelle.com/images/roffel.mp3" autostart="true" hidden="true">


- if you use getElementById(), then your element must have an id, not a name
id="sound1"

And, important, what DOCTYPE has your document?

gvmelle
01-23-2008, 01:42 PM
Thanks for your answer. Actually the javascipt code is in a .js file with the proper coding. Coding is corrected automatically by Wordpress. doctype is <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> the getElementById() I used with id instead of name, but is not nowhere working.

The question is:"what browser is more demanding: Firefox, Safari, Camino or Opera under MacOSX". Or is it because java 1.6 is still not available under OSX?

Kor
01-23-2008, 02:42 PM
if the javascript code is an external file, there should be no <script whichever> tags inside the code.

It could be, also, as you say, an OS problem, but this is over my knowledge so far...

gvmelle
01-23-2008, 03:20 PM
Thanks. There isn't. I just gave the scriptcode as example in case someone wanted to execute it. The <script...> tags are of course not in the js file.

I think I have to focus on the eval() statement.