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 :
<!DOCTYPE html  PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"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) :
<!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. Java Knowledge series 5

    Interface from user, not from implementor.(DIP) Interface-Oriented Programming. Interface or Abstrac ...

  2. 心得整理之一--RDLC多数据源多表

    我将项目中的一部分提炼出来,写了这个Demo. 先说一下需求, 从 API接口, 获取数据源, 调用RDLC 生成PDF文件. (后面还有涉及到使用福昕PDf阅读器进行设置文件自定义内容,以供外部程序 ...

  3. JavaScript 常用的Math对象

    Math.ceil(x); //返回x向上取整后的整数值. Math.floor(x); //返回x向下取整后的整数值.. Math.round(x); //返回四舍五入后的整数. Math.abs( ...

  4. 关于ASP.NET页面事件的知识点

    ASP是动态服务器页面(ActiveServerPage)的英文缩写,是微软公司开发的代替CGI脚本程序的一种应用,它可以与数据库和其它程序进行交互,是一种简单.方便的编程工具.那么关于ASP.NET ...

  5. NWERC 2013 - J (codeforces gym - 100405J)

    题目描述:给你一颗二叉树,保证每个点要么是叶子节点,要么有左右两个儿子.某些叶子节点上放着灯,请你移动最少的灯,使得整棵树平衡 对平衡的定义:对于树上的每个点左右儿子中灯数的差的绝对值≤1,那么这棵树 ...

  6. eclipse快捷键(个人经常使用的)

    周末闲来无聊,就把一直以来eclipse使用的快捷键梳理了下,希望对有需要的朋友有所帮助,绝对原创! 1.快速复制一行或者多行 首先选中你要复制的行,如果是一行,则鼠标焦点在那一行即可,如果是多行,可 ...

  7. 解决Wamp各版本中 Apache 文件列表图标无法显示

    Edit the following file manually and change the path to the icons folder (it appears times in the fi ...

  8. 2018.9.6 Java常考知识点总结

    一 Java中的值传递和引用传递(非常重要) 首先要明确的是:"对象传递(数组.类.接口)是引用传递,原始类型数据(整型.浮点型.字符型.布尔型)传递是值传递." 那么什么是值传递 ...

  9. caffe resize用interpolation

    opencv的resize默认的是使用双线性插值INTER_LINEAR,也可以是尝试其他的方式进行插值操作 if (param.random_interpolation_method()) { // ...

  10. c#转载的

    C#做项目时的一些经验分享 1.对于公用的类型定义,要单独抽取出来,放到单独的DLL中. 2.通过大量定义interface接口,来提高模块化程度,不同功能之间通过实现接口来面向接口编程. 3.如果项 ...