小书签
跳转到导航
跳转到搜索
外部链接
- BenjaminKeen.com,将网页放到不同大小的网页框架中
- Electric Development Blog: AutoTOC Bookmarklet, 生成页面的目录
javascript:var%20fullTOCText%20=%20%22Table%20of%20Contents%22;%20var%20matchStr%20=%20/^h[1-6]$/i;%20var%20resetSelect%20=%20false;%20var%20addMenuItem%20=%20false;%20function%20f()%20{%20if%20(document.getElementsByTagName(%22html%22).length%20&&%20(%20document.getElementsByTagName('h1').length%20||%20document.getElementsByTagName('h2').length%20||%20document.getElementsByTagName('h3').length%20||%20document.getElementsByTagName('h4').length%20||%20document.getElementsByTagName('h5').length%20||%20document.getElementsByTagName('h6').length%20))%20{%20var%20aHs%20=%20getHTMLHeadings();%20if%20(aHs.length%3E2)%20{%20addCSS(%20'#js-toc%20{position:%20fixed;%20left:%200;%20right:%200;%20top:%20auto;%20bottom:%200;%20height:%2020px;%20width:%20100%;%20vertical-align:%20middle;%20display:%20block;%20border-top:%201px%20solid%20#777;%20background:%20#ddd;%20margin:%200;%20padding:%203px;%20z-index:%209999;%20}\n'+%20'#js-toc%20select%20{%20font:%208pt%20verdana,%20sans-serif;%20margin:%200;%20margin-left:5px;%20background-color:%20#fff;%20color:%20#000;%20float:%20left;%20padding:%200;%20vertical-align:%20middle;}\n'+%20'#js-toc%20option%20{%20font:%208pt%20verdana,%20sans-serif;%20color:%20#000;%20}');%20var%20toc%20=%20document.createElement(window.opera?'tocuserjselem':'div');%20toc.id%20=%20'js-toc';%20tocSelect%20=%20document.createElement('select');%20tocSelect.setAttribute(%22onchange%22,resetSelect?%22if(this.value){location.href='#'+this.value;this.selectedIndex=0;}%22:%22location.href='#'+this.value;%22);%20tocSelect.id%20=%20'navbar-toc-select';%20tocEmptyOption%20=%20document.createElement('option');%20tocEmptyOption.setAttribute('value',);%20tocEmptyOption.appendChild(document.createTextNode(fullTOCText));%20tocSelect.appendChild(tocEmptyOption);%20toc.appendChild(tocSelect);%20document.body.style.paddingBottom%20=%20%2227px%22;%20document.body.appendChild(toc);%20for%20(var%20i=0,aH;aH=aHs[i];i++)%20{%20if%20(aH.offsetWidth)%20{%20op%20=%20document.createElement(%22option%22);%20op.appendChild(document.createTextNode(gs(aH.tagName)+getInnerText(aH).substring(0,100)));%20var%20refID%20=%20aH.id%20?%20aH.id%20:%20aH.tagName+'-'+(i*1+1);%20op.setAttribute(%22value%22,%20refID);%20document.getElementById(%22navbar-toc-select%22).appendChild(op);%20aH.id%20=%20refID;%20}%20}%20}%20}%20};%20function%20autoTOC_toggleDisplay()%20{%20if%20(document.getElementById('js-toc'))%20{%20if%20(document.getElementById('js-toc').style.display%20==%20'none')%20{%20document.getElementById('js-toc').style.display%20=%20'block';%20}%20else%20{%20document.getElementById('js-toc').style.display%20=%20'none';%20};%20}%20else%20{%20f();%20}%20}%20function%20getHTMLHeadings()%20{%20function%20acceptNode(node)%20{%20if%20(node.tagName.match(matchStr))%20{%20return%20NodeFilter.FILTER_ACCEPT;%20}%20return%20NodeFilter.FILTER_SKIP;%20}%20outArray%20=%20new%20Array();%20if%20(document.createTreeWalker)%20{%20var%20treeWalker%20=%20document.createTreeWalker(document.documentElement,%20NodeFilter.SHOW_ELEMENT,%20acceptNode,%20true);%20if%20(treeWalker)%20{%20var%20node%20=%20treeWalker.nextNode();%20while%20(node)%20{%20outArray.push(node);%20node%20=%20treeWalker.nextNode();%20}%20}%20}%20else%20{%20var%20els%20=%20document.getElementsByTagName(%22*%22);%20var%20j%20=%200;%20for%20(var%20i=0,el;el=els[i];i++)%20{%20if%20(el.tagName.match(matchStr))%20outArray[j++]%20=%20el;%20}%20}%20return%20outArray;%20}%20function%20addCSS(css)%20{%20var%20head,%20styleLink;%20head%20=%20document.getElementsByTagName('head')[0];%20if%20(!head)%20{%20return;%20}%20styleLink%20=%20document.createElement('link');%20styleLink.setAttribute('rel','stylesheet');%20styleLink.setAttribute('type','text/css');%20styleLink.setAttribute('href','data:text/css,'+escape(css));%20head.appendChild(styleLink);%20}%20function%20gs(s){%20s%20=%20s.toLowerCase();%20var%20ret%20=%20%22%22;%20for%20(var%20i=1;%20i%3C(s.substring(1)*1);i++)%20{%20ret%20=%20ret%20+%20%22\u00a0%20\u00a0%20%22;%20}%20return%20ret;%20}%20function%20getInnerText(el)%20{%20var%20s=;%20for%20(var%20i=0,node;%20node=el.childNodes[i];%20i++)%20{%20if%20(node.nodeType%20==%201)%20s%20+=%20getInnerText(node);%20else%20if%20(node.nodeType%20==%203)%20s%20+=%20node.nodeValue;%20}%20return%20s;%20}%20f();
- Bookmarklets (JavaScript Favelets), 一些小书签的集合,比较旧