我很想知道更多关于什么触发了Safari中的Reader选项以及什么没有.我不打算实施任何会阻止它的东西,但作为一项技术练习很好奇.
以下是我到目前为止所学到的一些基本知识:
Safari will provide the 'Reader' if, with a H tag, and the following:
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:
<p style="display:none;"> for P tags removes them from the countdisplay to none, and then showing them 230ms later with Javascript avoided the Reader option tooI'd be interested if anyone can determine this in full.
Qua*_*cal 11
将标记添加到可能"可读"的标记(例如p和div)可能会导致可读性算法忽略标记,从而降低分数,希望它不会触发Reader图标显示.
查看可读性源,其中一个区域是id和class属性,因为它对来自这两个属性的组合数据进行模式匹配.例如,添加"注释"类,就像这样
<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图标.
"你至少需要一个<h*>元素" - 这是完全错误的.这是一个例子:http://mathiasbynens.be/demo/safari-reader-test-3
我对其他Safari Reader问题的回答提供了更多信息.
您还可以阅读我关于启用Safari阅读器的博文,了解有关该主题的所有发现.