开发者

disable right click in fancybox

is there a way to disab开发者_运维问答le right click in fancybox. thanks


                onComplete: function() {
                        $("#fancybox-img").bind("contextmenu",function(e){
                            return false;
                        });
                    }

Add that to your options to disable right clicking on images in fancybox :)


Here is how I did that:

// fancybox
jQuery(".fancybox").fancybox({
    openEffect  : 'elastic',
    closeEffect : 'elastic',
    beforeShow: function () {
        /* Disable right click */
        $.fancybox.wrap.bind("contextmenu", function (e) {
        return false;
        });
        /* Disable drag */
        $.fancybox.wrap.bind("dragstart", function (e) {
        return false;
        });

    }
});


if you want to disable the right click on image, you need to grab the resultant selector and disable its context menu property.

example :

$('#fancybox-wrap').bind('contextmenu', function() {
    alert('sorry, Right Click Disabled :P'); //do stuff
    return false;
});


If you are using jQuery then try this. If this helps put some +1 :)

$(document).ready(function()
{
    // No right click
    $(document).bind('contextmenu', function() 
    {
        alert('no right click.');
        return false;
    });

});


I know it's too late to submit an answer. I just wanna help anyone who didn't know that fancybox add more parameter to protect the data. just add

    $('[data-fancybox]').fancybox({
    protect: true
    });

references

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜