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

后端 未结 9 1317
夕颜
夕颜 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:14

    No. Replacing with images is the fastest and the safest way. (Unless you are willing to switch to Flash/Java Applet/etc.)

    0 讨论(0)
  • 2020-12-01 13:17

    I don't think there's a way to disable the feature altogether and there should not be a way to disable it.

    However you can ensure that some text will not be found by Ctrl+F by writing it in away that the browser doesn't consider continous text.

    Using images is one approach that's relatively simply.

    Alternatively you can randomize the letters and re-arrange them with some CSS magic (my CSS-fu is too weak to give an example, unfortunately). For example if you want to "hide" the word "hello", then write out "lehol" with each letter in a separate <div> and apply some CSS styles so that visually the letters will be in the correct order.

    Note that this (and probably all other working solutions as well) will also break copy-and-paste of the text.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题