如何在网页中禁用Safari Reader

don*_*hoe 33 html safari

我很想知道更多关于什么触发了Safari中的Reader选项以及什么没有.我不打算实施任何会阻止它的东西,但作为一项技术练习很好奇.

以下是我到目前为止所学到的一些基本知识:

  • 您至少需要一个H标签
  • 它不是单独使用字符数,而是通过P标签的数量和长度
  • 可能会寻找句子'.' 和其他标准

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.

Qua*_*cal 11

将标记添加到可能"可读"的标记(例如pdiv)可能会导致可读性算法忽略标记,从而降低分数,希望它不会触发Reader图标显示.

查看可读性源,其中一个区域是idclass属性,因为它对来自这两个属性的组合数据进行模式匹配.例如,添加"注释"类,就像这样

<p class="myClass comment">...</p>
Run Code Online (Sandbox Code Playgroud)

将导致该元素被忽略.与"不太可能"的候选人匹配的模式是:

/combx|comment|disqus|foot|header|menu|rss|shoutbox|sidebar|sponsor/i
Run Code Online (Sandbox Code Playgroud)

在可能添加到可读性分数的元素上放置标记可以允许您禁用Reader图标.


Mat*_*ens 8

"你至少需要一个<h*>元素" - 这是完全错误的.这是一个例子:http://mathiasbynens.be/demo/safari-reader-test-3

我对其他Safari Reader问题的回答提供了更多信息.

您还可以阅读我关于启用Safari阅读器的博文,了解有关该主题的所有发现.

  • 为什么这是公认的答案?它回答了如何启用 Safari Reader。问题是如何禁用它。 (2认同)