Reputation: 2043
I didn't write this code and I'm having trouble figuring out why I'm getting the following the error at the first e.preventDefault()
. I've tried moving that code around within the .click
event handler, passing it to function(e){}
, replacing it with return false
, declaring it var e = $(this.href)
(don't laugh, I'm trying to learn), I've checked the value being returned in the a href
and it is returning the correct hash
. The video plays, but I'm getting this error when I run the IE debugger. Would someone please tell me how to properly debug and fix this. Thanks
HTML
<a href="#video1" class="blueBtn modal" style="width:150px;"><span>Watch Video <img width="10" height="17" src="images/bluebtn.png"></span></a></div>
Javascript
// FANCY BOX
$("a.modal").click(function(){
var inline=$(this).attr('href');
$.fancybox({
'transitionIn' : 'none',
'transitionOut' : 'none',
'href' : inline,
'onComplete' : function(){
$(inline+' .flowPlayer').videoPlayer();
$.fancybox.center(true);
},
'onClosed' : function(){loc();}
});
e.preventDefault();
});
$(".print").click(function(e){
window.open("print-docs/"+$(this).parent().attr('id')+".html","print","width=1,height=1");
e.preventDefault();
});
function loc(){
var location=window.location.href;
var replaceHash=location.replace(document.location.hash,"");
window.location.assign(replaceHash);
}
Upvotes: 2
Views: 13191
Reputation: 106385
Should be
$("a.modal").click(function(e) { // Note the "e" parameter
// etc
});
... instead, just like in the second click handler. See, both these functions are supplied with the jQuery Event object (a wrapper around native Event object) as a first parameter. But you still have to let JavaScript know how exactly this parameter will be referred to in your function. )
Upvotes: 5
Reputation: 4817
You missed the e
parameter:
$("a.modal").click(function(e){
e.preventDefault();
}
Upvotes: 2
Reputation: 83358
You need to add the e
parameter yourself:
$("a.modal").click(function(e){ //<------- right there
var inline=$(this).attr('href');
$.fancybox({
'transitionIn' : 'none',
'transitionOut' : 'none',
'href' : inline,
'onComplete' : function(){
$(inline+' .flowPlayer').videoPlayer();
$.fancybox.center(true);
},
'onClosed' : function(){loc();}
});
e.preventDefault();
});
Upvotes: 3