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. [一个小问题]Mainfest配置文件的version问题小结

    问题起源自己安装好产品的新build,然后用自己本地编译出来的其中一个DLL去替换到产品中,本来以为可以正常执行,但是却发现这个新DLL无法被Load,无法被使用. 从Event Viewer里找到了 ...

  2. centos命令行常用操作

    1.查看某个端口占用 lsof -i tcp:80 2.查看是否安装了防火墙 service iptables status 查看是否启用防火墙/etc/init.d/iptables status ...

  3. 笨办法学Python(二)

    习题 2: 注释和井号 程序里的注释是很重要的.它们可以用自然语言告诉你某段代码的功能是什么.在你想要临时移除一段代码时,你还可以用注解的方式将这段代码临时禁用.接下来的练习将让你学会注释: #-- ...

  4. STM32开发-MDK新建工程及配置

    本人也是接触stm32没多久,之前用的MDK是5.1,现在用的是5.13,MDK5.0之前的版本(本人简称旧版)和之后的版本(本人简称新版)新建工程有很大区别.对于刚开始用学stm32的新手来说,基本 ...

  5. 使用shell脚本实现在liunx上进行svn的上传下载更新功能

    最近有个功能,是需要从在liunx上拉取svn地址,并创建一个新文件进行提交,shell脚本如下 #!/bin/bash echo "Hello World !" myFile=& ...

  6. 【CCPC-Wannafly Winter Camp Day4 (Div1) C】最小边覆盖(简单题)

    点此看题面 大致题意: 给你一个边集的子集,问你这可不可能是这张图的最小边覆盖. 大致思路 考虑到,如果一条边连接的两个点度数都大于等于\(2\),则这条边完全可以删去. 因此,我们只要判断是否存在这 ...

  7. LA 3635 派

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...

  8. 下载Xcode历史版本方法

    1.打开链接:https://developer.apple.com/download/more 进入页面 2.在搜索框输入Xcode,回车搜索.如图,找到各种版本Xcode 搜索Xcode 3.双击 ...

  9. layui table 用法

    1.使用模板列 改变样式 获取嵌套数据{ field: '', width: '12%', title: '响应状态', sort: true, templet: function (d) { if ...

  10. 简单使用mybatis(idea中使用)

    首先创建一个maven项目 第一步:在pom.xml中添加依赖 <dependencies> <!--mybatis--> <dependency> <gro ...