简体   繁体   English

有人知道在FireFox 3.x中该做什么和不该做什么吗?

[英]Does anyone know the do's and don't of commenting in FireFox 3.x?

I decided to show a breaking version of what I am talking about. 我决定展示我所谈论的内容的最新版本。 It is not important how it messes up the layout, only that it causes the DIV element to be null.... 它是如何使布局混乱的并不重要,只是它会使DIV元素为空。

 <!-- [ top panel ] --><div id="top_panel">
 <!-- -------------------------------------- -->
    <script type="text/javascript">
   alert(document.getElementById('top_panel'));
    </script>
 </div>

The above code will return the element as null, every time.... if I increase or decrease the number of dashes it still fails as long as the interior dashes end with a closing pair of dashes. 上面的代码每次都会将元素返回为null。...如果增加或减少破折号,只要内部破折号以一对闭合的破折号结尾,它仍然会失败。 For the sake of example, I will use [open] and [close] to represent pairs of "--" dashes... 为了举例说明,我将使用[open]和[close]代表成对的“-”破折号...

So, the code ends up being interpreted this way to break: 因此,代码最终将以这种方式被解释为中断:

 <!-- [close][open][close][open][close][open][close][open][close] -->

In this example, it is the last [close] and the "-->" which now cause an open, hanging comment. 在此示例中,是最后一个[close]和“->”现在引起打开的,挂起的注释。

I only seem to run into comment-based issues in FF these days. 这些天我似乎只在FF中遇到过基于注释的问题。 All other browsers seem okay with anything I have thrown at them... 所有其他浏览器似乎都可以用我扔给他们的任何东西...

I KNOW that this is not considered legal commenting, but it still does not change the fact that I had to trip over this situation to become aware of the issue... I am hoping others can avoid the same simple problem and share their own twists on weird, comment-based issues in any browser... I am sure this is not the only instance of good commenting gone bad. 我知道这不是合法的评论,但仍然不能改变我不得不跳入这种情况以了解该问题的事实……我希望其他人可以避免同样的简单问题并分享自己的看法在任何浏览器中都会出现基于注释的怪异问题……我敢肯定,这并不是唯一一个好的注释变坏的实例。

I also understand that leaving a space after the "<" is a no-no as well: "<" + " " + "!" 我也明白,在“ <”之后留一个空格也是不可以的:“ <” +“” +“!” + "--" = Nooooo! +“-” =不!

Thanks for all your help, all! 谢谢您的所有帮助!

You can't use -- inside comments because it ends the comment. 您不能使用--内部注释,因为它会结束注释。 This isn't a Firefox thing - it's defined by the standards . 这不是Firefox,而是由标准定义的。 Any browser that doesn't treat -- as start/end of comment is doing it wrong and most likely will be bug-fixed eventually. 不把任何浏览器--作为注释的开始/结束时做错了,最有可能将是错误修正最终。

White space is not permitted between the markup declaration open delimiter("<!") and the comment open delimiter ("--"), but is permitted between the comment close delimiter ("--") and the markup declaration close delimiter (">"). 标记声明打开定界符(“ <!”)和注释打开定界符(“-”)之间不允许有空格,但注释关闭定界符(“-”)和标记声明闭合定界符(( “>”)。 A common error is to include a string of hyphens ("---") within a comment. 一个常见的错误是在注释中包含连字符(“ ---”)。 Authors should avoid putting two or more adjacent hyphens inside comments. 作者应避免在评论中添加两个或多个相邻的连字符。

Are you serving XHTML? 您正在提供XHTML吗? According to the XML standard , 根据XML标准

For compatibility, the string " -- " (double-hyphen) MUST NOT occur within comments. 为了兼容,注释中不得出现字符串“-”(双连字符)。

Edit : the same restriction exists in regular HTML, too . 编辑常规HTML中也存在相同的限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有谁知道为什么这种音频在FireFox中不起作用? - Does anyone know why this audio won't work in FireFox? Firefox 3.x中的PNG背景图像消失并且无法加载 - PNG background images in Firefox 3.x disappear and do not load 有人知道是否有用于使FireFox扩展程序在Chrome中运行的Chrome插件吗? - Does anyone know if there is a Chrome plugin for making FireFox extensions work in Chrome? CSS.important 似乎在 jQuery/Firefox 3.x 中不起作用 - CSS !important doesn't seem to work in jQuery/Firefox 3.x 通过编辑omni.ja崩溃FF移动Firefox 13的起始元素,任何人都知道如何正确地执行此操作? - Moving Firefox 13's startpage elements by editing omni.ja crashes FF, anyone know how to do this properly? 我的JavaScript平滑滚动无法滚动到Firefox中的正确位置,有人知道我在做什么错吗? - My javascript smooth scroll doesn't scroll to the right place in Firefox, does anyone know what I'm doing wrong? 使用 Python 3.x 启动 Firefox - Launch Firefox with Python 3.x 用于评论的 Jupyter Notebook 快捷方式在 Firefox 中不起作用 - Jupyter Notebook shortcuts for commenting do not work in Firefox 图像未出现在Firefox中 - Image's don't appear in Firefox Firefox 3.x的后备操作打算做什么? - What is intended fallback action for Firefox 3.x?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM