我怎样才能有一个空白标题页? [英] How can I have a Blank Title Page?

查看:160
本文介绍了我怎样才能有一个空白标题页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <!DOCTYPE html> 
< html>
< head>
< meta charset =UTF-8/>
< script> document.title =;< / script>
< / head>
< / html>它可以在IE和Firefox中使用,但Chrome不起作用。
那么,在W3C标准。看来空白的标题是不允许的!!


在用户界面中引用文档时,用户代理应该使用文档的标题。当以这种方式使用标题元素的内容时,应使用该标题元素的方向性来设置文档标题在用户界面中的方向性。


$ b $根据HTML5 CR,标题元素是必需的,除非文档是iframe srcdoc文件或标题信息是否可从上级协议获得(这在 元素)。

可以通过赋值给JavaScript来设置标题 document.title ,在实践中根据HTML5 CR。当然,对于标题的许多重要用途来说这是无效的,因为这只发生在浏览器中。

HTML5 CR还指定 title 元素不得为空或只包含一个空间。更确切地说,内容必须是不是元素间空格的文本。



document.title 的值没有相应的要求。但是,HTML5指定了分配时,前导空白和尾随空白被剥离。如果你在赋值 document.title =之后测试 document.title 的值,你会看到值是空字符串,而不是空格。

浏览器与文档标题有什么不同(使用< title> / code>元素或通过赋值给 document.title )。他们可能以各种方式在其用户界面中显示它。如果标题设置为空字符串或根本没有设置,浏览器通常会使用文档的文件名(可能以某种方式修改)来代替标题。这是怎么回事在Chrome,Firefox和IE(在Windows上)时显示文档标题作为选项卡的名称。 (我不知道这个问题是什么意思,说在IE和Chrome中设置标题空白works)。

在大多数情况下,文档的空标题没有任何意义,除了出版一本没有名字的书以外是有意义的。但是,如果你有一个使用情况,你想要标题(如浏览器在某些情况下显示),您可以部署各种技巧。

例如,NO- BREAK SPACE U + 00A0根据定义不是HTML中的空白字符,所以您可以在HTML或<$中使用< title>& nbsp;< / title> c $ c> document.title ='\\\ '在JavaScript中。标题将看起来像空白,但它在技术上不是空的,所以它将被用于浏览器。



由于NO-BREAK仍占用空间(它实际上用字形,只是一个完全空白的字形),你可以使用LEFT-TO-RIGHT MARK U + 200E来代替;它是一个不可见的(零宽度)控制字符。在HTML中,您可以使用< title>& lrm;< / title> 。或者,您可以在JavaScript中使用 document.title ='\\\‎'


I'm using

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8"/>
    <script>document.title=" ";</script>
  </head>
</html>

It works in IE and Firefox, but Chrome doesn't work. Well, in W3C standard. It seems that blank title is not allowed?!

User agents should use the document's title when referring to the document in their user interface. When the contents of a title element are used in this way, the directionality of that title element should be used to set the directionality of the document's title in the user interface.

解决方案

According to HTML5 CR, the title element is required, unless "the document is an iframe srcdoc document or if title information is available from a higher-level protocol" (this is specified in the description of the head element).

It is possible to set the title in JavaScript by an assignment to document.title, in practice and according to HTML5 CR. Of course, this is ineffective for many important uses of the title, since this only takes place in a browser.

HTML5 CR also specifies that the title element must not be empty or contain just a space. More exactly, the content must be text that is not inter-element whitespace.

There is no corresponding requirement for the value of document.title. However, HTML5 specifies that on assignment, leading and trailing whitespace is stripped off. If you test the value of document.title after the assignment document.title = " ", you will see that the value is the empty string, not a space.

Browsers differ in what they do with the document title (set with a <title> element or via assignment to document.title). They may display it in various ways in their user interface. If the title is set to the empty string or is not set at all, browsers typicallty use the file name of the document, possibly somehow modified, in place of a title. This is what happens e.g. in Chrome, Firefox, and IE (on Windows) when they show document title as the name of a tab. (I don’t know what the question means by saying that setting title blank "works" in IE and Chrome.)

In most cases, an empty title for a document makes no sense, any more than it would make sense to publish a book without a name. But if you have a use case where you want to make the title (as shown by browsers in some contexts), you can deploy various tricks.

For example, NO-BREAK SPACE U+00A0 is by definition not a whitespace character in HTML, so you could use <title>&nbsp;</title> in HTML or document.title='\u00A0' in JavaScript. The title will then look like blank, but it’s technically not empty, so it will be used browsers.

Since NO-BREAK still occupies space (it’s really shown with a glyph, just a completely blank glyph), you might use LEFT-TO-RIGHT MARK U+200E instead; it is an invisible (zero-width) control character. In HTML, you could use <title>&lrm;</title>. Alternatively, you could use document.title='\u200E' in JavaScript.

这篇关于我怎样才能有一个空白标题页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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