专注于为中小企业提供成都网站设计、成都做网站服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业新城免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了1000+企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。
HTML5
与类相关的扩充
1、getElementsByClassName()方法
改方法接受一个参数,即一个包含一或多个类名的字符串,返回带有指定类的所有元素的NodeList。传入多个类型时,先后顺序不重要。
1 //取得所有类中包含"username"和"current"的元素,类名的先后顺序不重要2 var allCurrentUsername = document.getElementsByClassName('username current');3 //取得ID为'myDiv'的元素中都带有类名"selected"的所有元素4 var selected = document.getElementById('myDiv').getElementsByClassName('selected');调用这个方法时,只有位于调用元素子树中的元素才会返回。
2、classList属性
在操作类名时,需要通过className属性添加,删除和替换类名。因为className中是一个字符串,所以即使只修改字符串的一部分,也必须每次都设置整个字符串。HTML5新增加了一种操作类名的方式,那就是为所有元素都添加classList属性。这个classList属性是新集合类型DOMTiokenList的实例。与其他DOM集合类似,DOMTokenList有一个表示自己包含多少元素的length属性,而要取得每个元素可以使用item()方法,也可以使用方括号语法。此外,这个新类型还定义如下方法:
//Alt + 41406、Alt + 41407
【1】add(value):将给定的字符串添加到列表中,如果以存在就不在添加;
【2】contains(value):表示列表中是否存在给定的值,如果存在就返回true,反之返回false;
【3】remove(value):从列表中删除给定的字符串;
【4】toggle(value):如果列表中存在给定的值,删除它,如果列表中没有给定的值,添加它;
1 //添加"currrent"类2 div.classList.add('current');3 //切换"user"类4 div.classList.toggle('user');
焦点管理
document.activeElement属性,这个属性始终会引用DOM中当前获得了焦点的元素。元素获得焦点的方法通常有页面加载,用户输入和在代码中调用focus()方法。
1 var button = document.getElementById('myButton');2 button.focus();3 console.log(document.activeElement === button); //true默认情况下,文档刚刚加载完成时,document.activeElement的值为document.body,当文档加载时document.activeElement的值为null;
document.hasFocus()方法,这个方法用于确定文档是否获得了焦点;
1 var button = document.getElementById('myButton');2 button.focus();3 console.log(documet.hasFocus()); //true
HTMLDocument的变化
HTML5扩展了HTMLDocument,增加了新的功能
1、readyState属性
它有两个可能的值
【1】loading,正在加载文档。
【2】complete,已经加载完文档。
使用document.readyState的最恰当方式,就是通过它来实现一个指示文档已经加载完成的指示器
2、兼容模式
在标准模式下,document.compatMode的值等于"CSS1Compat",而在混杂模式下,document.compatMode的值等于"BackCompat"。
3、head属性
作为对document.body引用文档的
元素的补充,HTML5新增了document.head属性,引用文档的元素,要引用文档的元素,可以结合使用这个属性和另一种后备方法。
1 var head = document.head || document.getElementsByTagName('head')[0];
字符集属性
HTML5新增了几个与文档字符集有关的属性,其中,charset属性表示文档中实际使用的字符集,也可以用来指定新字符集。默认情况下,这个属性的值为"UTF-16";
1 console.log(document.charset); //"UTF-16"2 document.charset = "UTF-8";
另一个属性是defaultCharset,表示根据默认浏览器及操作系统的设置,当前文档默认的字符集应该是什么。如果文档没有默认的字符集,那charset和defaultCharset属性的值可能会不一样,例如:
1 if(document.charset != document.defaultCharset){2 console.log("Custom character set being used.");3 }
自定义数据属性
HTML5规定可以为元素添加非标准的属性,但要添加前缀data-,目的是为元素提供与渲染无关的信息,或者提供语义信息。这些属性可以任意添加、随便命名,只要以data-开头即可
1
添加了自定义属性后,可以通过dataset属性来访问自定义属性的值,只不过属性名没有data-前缀

1 var div = document.getElementById('myDiv');2 3 //取得自定义属性的值4 var appid = div.dataset.appid;5 var myName = div.dataset.myName;6 7 //设置值8 div.dataset.appid = 23456;9 div.dataset.myName = "Michael";
如果需要给元素添加一些不可见的数据以便进行其他处理,那就要用到自定义数据属性
插入标记
在读模式下,innerHTML属性会返回与调用元素的所有子节点(包括元素、注释和文本节点)对应的HTML标记;在写模式下,innerHTML会根据指定的值创建新的DOM树,然后用这个DOM树完全替换调用元素原先的所有子节点;下面是一个例子

1 2
This is a paragraphwith a list following it.
3
4 - Item 1
5 - Item 2
6 - Item 3
7
8

对于上面的
来说,他的innerHTMl属性会返回如下字符串。
1 This is a paragraphwith a list following it.
2
3 - Item 1
4 - Item 2
5 - Item 3
6
不要指望所有浏览器返回的innerHTML值完全相同,使用innerHTML属性也有一些限制。比如,在大多数浏览器中,通过innerHTML插入
基本
文件
流程
错误
SQL
调试
- 请求信息 : 2026-06-09 08:50:40 HTTP/1.1 GET : /article/jojhpo.html
- 运行时间 : 3.1349s ( Load:0.0064s Init:2.4967s Exec:0.6226s Template:0.0092s )
- 吞吐率 : 0.32req/s
- 内存开销 : 2,263.53 kb
- 查询信息 : 12 queries 5 writes
- 文件加载 : 36
- 缓存信息 : 0 gets 0 writes
- 配置加载 : 130
- 会话信息 : SESSION_ID=eunh4sjsio4dbmkppi4vqfe137
- /www/wwwroot/tsicrk.com/index.php ( 1.09 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/ThinkPHP.php ( 4.61 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Think.class.php ( 12.26 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Storage.class.php ( 1.37 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Storage/Driver/File.class.php ( 3.52 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Mode/common.php ( 2.82 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Common/functions.php ( 53.56 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Hook.class.php ( 4.01 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/App.class.php ( 13.49 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Dispatcher.class.php ( 14.79 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Route.class.php ( 13.36 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Controller.class.php ( 11.23 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/View.class.php ( 7.59 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/BuildLiteBehavior.class.php ( 3.68 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/ParseTemplateBehavior.class.php ( 3.88 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/ContentReplaceBehavior.class.php ( 1.91 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Conf/convention.php ( 11.15 KB )
- /www/wwwroot/tsicrk.com/App/Common/Conf/config.php ( 2.14 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Lang/zh-cn.php ( 2.55 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Conf/debug.php ( 1.49 KB )
- /www/wwwroot/tsicrk.com/App/Home/Conf/config.php ( 0.31 KB )
- /www/wwwroot/tsicrk.com/App/Home/Common/function.php ( 3.33 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/ReadHtmlCacheBehavior.class.php ( 5.62 KB )
- /www/wwwroot/tsicrk.com/App/Home/Controller/ArticleController.class.php ( 6.02 KB )
- /www/wwwroot/tsicrk.com/App/Home/Controller/CommController.class.php ( 1.60 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Model.class.php ( 60.11 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Db.class.php ( 32.43 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Db/Driver/Pdo.class.php ( 16.74 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Cache.class.php ( 3.83 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Cache/Driver/File.class.php ( 5.87 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Template.class.php ( 28.16 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Template/TagLib/Cx.class.php ( 22.40 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Template/TagLib.class.php ( 9.16 KB )
- /www/wwwroot/tsicrk.com/App/Runtime/Cache/Home/7540f392f42b28b481b30614275e4e55.php ( 17.71 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/WriteHtmlCacheBehavior.class.php ( 0.97 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/ShowPageTraceBehavior.class.php ( 5.24 KB )
- [ app_init ] --START--
- Run Behavior\BuildLiteBehavior [ RunTime:0.000006s ]
- [ app_init ] --END-- [ RunTime:0.000030s ]
- [ app_begin ] --START--
- Run Behavior\ReadHtmlCacheBehavior [ RunTime:0.000270s ]
- [ app_begin ] --END-- [ RunTime:0.000288s ]
- [ view_parse ] --START--
- [ template_filter ] --START--
- Run Behavior\ContentReplaceBehavior [ RunTime:0.000062s ]
- [ template_filter ] --END-- [ RunTime:0.000086s ]
- Run Behavior\ParseTemplateBehavior [ RunTime:0.006397s ]
- [ view_parse ] --END-- [ RunTime:0.006423s ]
- [ view_filter ] --START--
- Run Behavior\WriteHtmlCacheBehavior [ RunTime:0.000157s ]
- [ view_filter ] --END-- [ RunTime:0.000170s ]
- [ app_end ] --START--
- 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') LIMIT 1' at line 1
[ SQL语句 ] : SELECT `id`,`pid`,`navname` FROM `cx_nav` WHERE ( id= ) LIMIT 1
- 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') LIMIT 1' at line 1
[ SQL语句 ] : SELECT `id`,`navname` FROM `cx_nav` WHERE ( id= ) LIMIT 1
- 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
[ SQL语句 ] : SELECT `id`,`navname` FROM `cx_nav` WHERE ( pid= )
- [8] Undefined index: pid /www/wwwroot/tsicrk.com/App/Home/Controller/ArticleController.class.php 第 47 行.
- [8] Undefined index: db_host /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Db.class.php 第 120 行.
- [8] Undefined index: db_port /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Db.class.php 第 121 行.
- [8] Undefined index: db_name /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Db.class.php 第 122 行.

3.1349s
