What not to do : 
In theory , you could use JavaScript to add important content to a web page.
However, that would be a very bad idea, because there would be no room for graceful degradation.
Visitors lacking the necessary JavaScript support would never see the content. 
 
The markup : HTML, XHTML, or HTML5
For the markup, its up to you whether to use HTML or XHML.
The important thing is that whichever document type you choose, the markup validates to the 
specified DOCTYPE declaration.
 
With XHTML, all the tags must be closed. That includes stand-alone elements like <img> and <br>
which must be written with a closing slash: <img /> and <br />
To use the XHTML DOCTYPE, you include this at the begining of your document :
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strick.dtd" >
Another option that you may like even better is to use the HTML5 DOCTYPE. The HTML5 DOCTYPE is 
very simple (just 15 characters) :
  1. <!DOCTYPE html>
   
You can create useful scripts like these using just a handful of DOM methods and porperties.
Having well-structured markup is an important prerequisite when you are enhancing content 
with DOM scripts.
            As a recap, these are the most useful methods for retrieving information from a document :
  • getElementById
  • getElementsByTagName
  • getElementsByName
  • getAttribute
            These are the most useful methods for attaching information to a document :
  • createElement
  • createTextNode
  • appendChild
  • insertBefore
  • setAttribute
By combining those methods, you can create very powerful DOM scripts.
Always remember to use JavaScript to enhance the content of your documents, rahter than 
creating any core content directly with the DOM.

Enhacing the content with JavaScript的更多相关文章

  1. How to get a DOM element's ::before content with JavaScript?

    How to get a DOM element's ::before content with JavaScript? https://stackoverflow.com/questions/443 ...

  2. javascript 技巧总结积累(正在积累中)

    1.文本框焦点问题 onBlur:当失去输入焦点后产生该事件 onFocus:当输入获得焦点后,产生该文件 Onchange:当文字值改变时,产生该事件 Onselect:当文字加亮后,产生该文件 & ...

  3. Meta标签详解(HTML JAVASCRIPT)

    Meta标签详解,在网上转的,希望对大家有用 您的个人网站即使做得再精彩,在“浩瀚如海”的网络空间中,也如一叶扁舟不易为人发现,如何推广 个人网站,人们首先想到的方法无外乎以下几种: ● 在搜索引擎中 ...

  4. javascript基础部分

    javascript基础部分 1  数据类型: 基础数据类型(通过typeof来检测):Number,string,undefined,null,boolean,function typeof只能检测 ...

  5. javascrit2.0完全参考手册(第二版) 第1章第1节 在XHTML文档中增加javascript

    通常,向文档中增加script脚本使用<script>元素,在HTML中增加脚本的方式有4中: (1)放到<script></script>块中: (2)<s ...

  6. Android WebView和JavaScript交互

    JavaScript在现在的网页设计中用得很多,Android 的WebView可以载入网页,WebView也设计了与JavaScript通信的桥梁.这篇主要介绍一下WebViewk控件如何和Java ...

  7. Javascript:浮动的导航条

    代码主体及说明 Javascript部分: /** * @函数名:flexScroll * @功能:滚动超出一定高度,指定元素悬浮 * @两个参数:target_id:目标元素id;topEle:限定 ...

  8. webview与JavaScript之间的交互

    据说WebView的强大之处就是能和JavaScript进行交互调用. 参考博客:http://droidyue.com/blog/2014/09/20/interaction-between-jav ...

  9. Android 中Java和JavaScript交互入门

    如何实现JavaScript 和java 交互 实现Java和js交互十分便捷.通常只需要以下几步. WebView开启JavaScript脚本执行 WebView设置供JavaScript调用的交互 ...

随机推荐

  1. eclipse 上使用tomcat 启动项目,项目目录下无.class 文件

    摘要:在使用eclipse 启动taomcat时,项目报错,但将项目打成war包单独部署到tomcat时,则项目正常,通过对比两次部署文件发现,从eclipse直接启动tomcat时,部署到tomca ...

  2. CRUD全栈式编程架构之更精简的设计

    精简的程度 ViewModel精简 服务精简 控制器精简 Index.cshmtl精简 AddOrEdit.cshtml精简 效果:最精简的情况下,只需要写Entity这一个数据库实体然后加上一些简单 ...

  3. ELF文件中section与segment的区别

    http://blog.csdn.net/joker0910/article/details/7655606 1. ELF中的section主要提供给Linker使用, 而segment提供给Load ...

  4. DP上课覆盖知识点,POJ(1513)

    题目链接:http://poj.org/problem?id=1513 解题报告: 思路: 知识点从第二个开始扫,递推表达式是:minlec[i]=min(minlec[k])+1,并且要保证,tim ...

  5. vuejs组件参数校验

    父组件向子组件传递一些参数,那么子组件有权对这些参数进行一个校验,这个就是组件参数校验 需求:父组件传递过来的必须是个字符串,这个要怎么去校验呢 <div id='root'> <c ...

  6. 2017.10.14 Java的流程控制语句switch&&随机点名器

    今日内容介绍 1.流程控制语句switch 2.数组 3.随机点名器案例 ###01switch语句解构     * A:switch语句解构       * a:switch只能针对某个表达式的值作 ...

  7. TypeScript学习-TypeScript环境配置

    http://blog.csdn.net/shi_weihappy/article/details/49332091

  8. Spring MVC的一些学习笔记-入门配置和HttpMessageConverter

    1.初步配置 [1]. 配置web.xml以及在web.xml中配置DispatcherServlet: <context-param> <param-name>context ...

  9. Advanced Memory Allocation 内存分配进阶[转]

    May 01, 2003  By Gianluca Insolvibile  in Embedded Software Call some useful fuctions of the GNU C l ...

  10. 基于java开发的开源代码GPS北斗位置服务监控平台

    最近在研究位置服务平台,基于全球卫星定位技术(GNSS).互联网技术.空间地理信息技术(GIS).3G/4G无线通信技术,面向全国公众用户建立大容量.实时.稳定的位置信息服务运营平台.实现管理目标的实 ...