Reputation: 35
It is not working,i need onclick base not id based code,please help me
<div onclick="favTheater(id)">
<img src="#"/>
</div>
<script type="text/javascript">
function favTheater(id){
alert("dsfdsf"+id);
var e = window.event;
e.stopPropagation();
e.preventDefault();
window.location.href="http://www.google.co.in/";
}
</script>
Upvotes: 0
Views: 158
Reputation: 382150
A few problems with your code :
favTheater(id)
on click but you didn't define an id,window.event
, which exists only on IE. Note also that those old IE browsers didn't have stopPropagation
(it came with IE9),http://www.google.co.in/
,preventDefault
is useless.So, your code is "not working", but it's hard to incriminate stopPropagation
Upvotes: 3