如何在网页中禁用Safari阅读器 [英] How to disable Safari Reader in a web page

查看:668
本文介绍了如何在网页中禁用Safari阅读器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很想知道更多关于什么会触发Safari中的Reader选项,哪些不会。我不打算实施任何可以禁用它的东西,但作为技术练习很好奇。



这是我迄今为止学到的一些基本玩法:




  • 您至少需要一个 H 标签 可能会寻找句子中断'。'和其他标准



如果使用 H 标签,Safari将提供'Reader'以及以下内容:


  • 1 p 标记,2417个字符

  • 4 P 标记,1527个字符

  • 5 P 标记,1150个字符

  • 6 P 标记,862个字符 / ul>

    如果您从上述任何一项中减去1个字符,则'Reader'选项不可用。

    I应该注意到, H 标签的字符数量起到了一部分作用,但是当我确定结果ab时,可悲的是没有意识到这一点OVE。假设有20个以上的字符供 H 标签使用,并在上述结果中修复。



    其他有趣的事情:


    • P 标记设置< p style =display:none;> 将它们从计数中删除

    • 设置显示 none ,然后显示他们在230ms以后用Javascript避免了阅读器选项



    如果有人能完全确定这一点,我会很感兴趣。

    解决方案

    您至少需要一个< h *> 元素 - this根本不正确。下面是一个例子: http://mathiasbynens.be/demo/safari-reader-test- 3





    您也可以阅读 关于启用Safari阅读器的博客文章 ,以获取关于此主题的所有发现。


    I'm curious to know more about what triggers the Reader option in Safari and what does not. I wouldn't plan to implement anything that would disable it, but curious as a technical exercise.

    Here is what I've learned so far with some basic playing around:

    • You need at least one H tag
    • It does not go by character count alone but by the number of P tags and length
    • Probably looks for sentence breaks '.' and other criteria

    Safari will provide the 'Reader' if, with a H tag, and the following:

    • 1 P tag, 2417 chars
    • 4 P tags, 1527 chars
    • 5 P tags, 1150 chars
    • 6 P tags, 862 chars

    If you subtract 1 character from any of the above, the 'Reader' option is not available.

    I should note that the character count of the H tag plays a part but sadly did not realize this when I determined the results above. Assume 20+ characters for H tag and fixed throughout the results above.

    Some other interesting things:

    • Setting <p style="display:none;"> for P tags removes them from the count
    • Setting display to none, and then showing them 230ms later with Javascript avoided the Reader option too

    I'd be interested if anyone can determine this in full.

    解决方案

    "You need at least one <h*> element" — this is simply incorrect. Here’s an example: http://mathiasbynens.be/demo/safari-reader-test-3

    My answer on the other Safari Reader question provides some more info.

    You could also read my blog post on enabling Safari Reader for all my findings on the subject.

    这篇关于如何在网页中禁用Safari阅读器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆