Is it possible to disable Ctrl + F of find in page?

后端 未结 9 1355
夕颜
夕颜 2020-12-01 12:39

I have a puzzle site and its an awful way of cheating. Its okay if only partially, but can it be done?
Something I had in mind was replacing the letters with images, but

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-01 13:19

    You can disable the keyboard shortcut in most browsers (IE9, Firefox, Chrome, Opera), but you can't stop someone using Find by clicking it in the browser.

    Here's some jQuery-powered JavaScript that does it:

    $(window).keydown(function(e){
        if ((e.ctrlKey || e.metaKey) && e.keyCode === 70) {
            e.preventDefault();
        }
    });
    

    Taken from http://caniuse.com/, where this feature regularly irritates me. On that site, it's used to make CTRL+F do a custom search on the page, instead of disabling it completely.

提交回复
热议问题