Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
119 views
in Technique[技术] by (71.8m points)

javascript - HTML“no-js”类的目的是什么?(What is the purpose of the HTML “no-js” class?)

I notice that in a lot of template engines, in the HTML5 Boilerplate , in various frameworks and in plain php sites there is the no-js class added onto the <HTML> tag.(我注意到在很多模板引擎中,在HTML5 Boilerplate中 ,在各种框架和普通的php站点中,在<HTML>标记上添加了no-js类。)

Why is this done?(为什么这样做?) Is there some sort of default browser behavior that reacts to this class?(是否存在某种对此类做出反应的默认浏览器行为?) Why include it always?(为什么总是包括它?) Does that not render the class itself obsolete, if there is no no-"no-js" case and html can be addressed directly?(如果没有no-“no-js”情况并且html可以直接解决,那么这不会使类本身过时吗?) Here is an example from the HTML5 Boilerplate index.html:(以下是HTML5 Boilerplate index.html中的示例:) <!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]--> <!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]--> <!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]--> <!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]--> <!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]--> As you can see, the <html> element will always have this class.(如您所见, <html>元素将始终具有此类。) Can someone explain why this is done so often?(有人可以解释为什么经常这样做吗?)   ask by Swader translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

When Modernizr runs, it removes the "no-js" class and replaces it with "js".(当Modernizr运行时,它会删除“no-js”类并用“js”替换它。)

This is a way to apply different CSS rules depending on whether or not Javascript support is enabled.(这是一种应用不同CSS规则的方法,具体取决于是否启用了Javascript支持。) See Modernizer's source code .(请参阅Modernizer的源代码 。)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...