读JS高级API笔记_(DOM&&DOM2&&DOM3)哎呀——园龄才9个月啊

---恢复内容开始---

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>DOM2 && DOM3  || HTML5DOMAPI</title>
</head>
<body>
<div>
    <p>12312</p>
    <ul>
        <li>1</li>
        <li>11</li>
        <li>111</li>
        <li>1111</li>
    </ul>
</div>
<script>
    root = document.querySelector('div');
    //带命名空间的文档结构
    /*
    <xhtml:body xhtml:class="xx">
    </xhtml:body>
    */
    root.localName //不带XML空间前缀的tagName
    document.doctype.publicId
    //"-//W3C//DTD XHTML 1.0 Transitional//EN"
    document.doctype.systemId
    //"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
    
    document.importNode; //解决不同DOM类型之间的DOM&node移动操作
    document.defaultView //window 当前的window环境
    //document.contentDocument /*for标准*/|| document.contentWindow.document /*for IE*/
    document.styleSheets
    document.scripts
    
    /* style */
    style = {
        cssText : '', //样式
        length : '', //有几个样式
        getPropertCssValue : '',
        getPropertyValue : '',
        "item(index)" : '', //返回第索引个的样式
        removeProperty : '',
        setProperty : ''
    };
    
    //HTML5元素遍历 //NodeIterator ,treeWalker
    var iterator = document.createTreeWalker(root,NodeFilter.SHOW_ELEMENT,filter,false);
    function filter( node ){ //有点想 ARRAY.prototype.sort方法
        return node.tagName.toLowerCase() === 'li' ?
        NodeFilter.FILTER_ACCEPT :  //接受这个节点
        NodeFilter.FILTER_SKIP      //过滤掉这个节点
    };
    node = iterator.nextNode(); //专有方法 nextNode() 和previousNode() ,取得节点的元素
    while( node != null){
        console.log(node.tagName);
        node = iterator.nextNode();
    };
    //获取range方法,
    var range = document.createRange();
    range.selectNode(root);
    console.log( range );
    //range.setStart(obj,offset)
    //range.setEnd(obj,offset)
    //range.extraContent;
    //range.cloneContent;
    //range.insertNode;
    //range.surrandContent(span);
    //range.collapse( true or false );
    //range.compareBoundaryPoints(0 || 1 || 2 || 3,range2);
    root.classList;
    root.classList.contain;
    root.classList.add;
    root.classList.remove;
    root.classList.toggle;
    
    document.activeElement; //默认body
    /*
    data-xx ; dataSet.xx = 1; 存数据的,实现更快访问
    */;
    
    //[
        //beforebegin,
        //afterbegin,
        //beforeend,
        //afterend
    //]
    root.insertAdjacentElement
    root.insertAdjacentText
    root.insertAdjacentHTML
    root.insertAdjacentBefore
    
    //HTML5 scrollAPI
    document.body.scrollIntoView()
    
    document.domain //可以实现同一个域名不同二级域名的跨域,但是只能document.domain更改一次,否则会报错
    root.nodeType  === '3' ? root.normalize()&&root.splitText('aaa/*这个是切割标志符*/') : ''
    document.createComment('\'xxx');
    var aDiv = document.getElementsByTagName('div'); //这个aDiv是根据页面自动更新的
</script>
</body>
</html>

 //娃哈哈,博客园的恢复功能不错

---恢复内容结束---

posted @ 2013-12-22 00:51  方方和圆圆  阅读(439)  评论(0编辑  收藏  举报

再过一百年, 我会在哪里?