tags:

views:

39

answers:

3

Hi all.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><meta http-equiv="content-type" content="text/xhtml; charset=utf-8" />
<script type="text/javascript" language="javascript" src="/js/jquery-1.3.2.min.js?42"></script>
<script type="text/javascript">
function play(id, song)
{
 alert(id+song);
}
</script>
</head>
<body>
 <img id="play" src="/images/miniplay.png" alt="Play"/>

 <img id="oi1" class="oi" src="/images/miniplay.png" alt="Play" onclick="play(24, '325s2sq2h');"/>
 <img id="oi2" class="oi" src="/images/miniplay.png" alt="Play" onclick="play(35, 'skf8s2n2');"/>
</body>
</html>

Firebug gives an error

play is not a function [Break on this error] play (24, "325s2sq2h");

How fix it? Thank you!

+4  A: 

The problem is with the img with id="play" - it's conflicting with your function name; rename one or the other

Marek Karbarz
Agreed, I was just about to post the same answer. However, I'm not quite sure if this is to be considered a browser bug or correct behaviour; do DOM `id` names not belong in a different namespace than JavaScript code?
stakx
@stakx - I was wondering the same thing and this is what I found: http://stackoverflow.com/questions/1415747/javascript-function-and-form-name-conflict
Marek Karbarz
A: 

Either rename the function, or change the id of the first image. Currently they are both play, so they conflict.

Dave Hinton
A: 

Marek's right. That must b the one ;)

Swoosh