2012-03-28, 17:19:46
vasitellapahki Wrote:Code:<script type="text/javascript">
$(document).ready(function()
{
$('img').bind("contextmenu", function(e){ return false; })
});
</script>
This works as expected but it does not disable right click in Fancybox popup – I’ve tried various solutions which I found but can’t figure out where the function should be in… anyone have a suggestion?
Your problem is that $('img') only contains the images that currently exist in the DOM. Fancybox creates a new IMG element when it shows its box, and this new image never got your function set to it. What you actually want to do is bind the action to an existing element like the document but only trigger it when an image is clicked. Like so:
Code:
$(function(){
$(document).on('contextmenu', 'img', function(){ return false; });
});
I still do not agree with this, but there you go. You can change the img selector in the .on() function to something more specific if you only want this to apply to images shown in Fancybox.
“Don’t forget the important ˚ (not °) on the a,†says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!