Thành viên:David/monobook.js
Bách khoa toàn thư mở Wikipedia
Cache: Sau khi lưu biểu mẫu này, phải bỏ thông tin vùng đệm (cache) của trình duyệt cho những thay đổi hiện ra được: Mozilla, Firefox, Netscape, Safari: Giữ nút Shift
trong khi bấm Reload
, hay bấm Ctrl
+Shift
+R
. Internet Explorer: Bấm Ctrl
+F5
. Opera, Konqueror: Bấm F5
.
Nếu bạn viết mã JavaScript, chú ý đọc hướng dẫn để tránh mâu thuẫn với mã mặc định của mạng.
/* Chia ra Thành viên:Mxn/Trang Chính 3 thành tab */ /* Dựa trên mã nguồn của wikibits.js */ // fold sections for Trang Chính // XXX: needs testing on IE/Mac and safari // more comments to follow function tabbedsects() { var container = document.getElementById('page-sects'); if (!container || !document.createElement) return; if (container.nodeName.toLowerCase() == 'a') return; // Occasional IE problem container.className = container.className + 'jsprefs'; var sections = new Array(); children = container.childNodes; var seci = 0; for (i = 0; i < children.length; i++) { if (children[i].nodeName.toLowerCase() == 'div') { children[i].id = 'prefsection-' + seci; children[i].className = 'prefsection'; if (is_opera || is_khtml) children[i].className = 'prefsection operaprefsection'; legends = children[i].getElementsByTagName('h2'); sections[seci] = new Object(); legends[0].className = 'mainLegend'; if (legends[0] && legends[0].firstChild.nodeValue) sections[seci].text = legends[0].firstChild.nodeValue; else sections[seci].text = '# ' + seci; sections[seci].secid = children[i].id; seci++; if (sections.length != 1) children[i].style.display = 'none'; else var selectedid = children[i].id; } } var toc = document.createElement('ul'); toc.id = 'preftoc'; toc.selectedid = selectedid; for (i = 0; i < sections.length; i++) { var li = document.createElement('li'); if (i == 0) li.className = 'selected'; var a = document.createElement('a'); a.href = '#' + sections[i].secid; a.onmousedown = a.onclick = uncoversection; a.appendChild(document.createTextNode(sections[i].text)); a.secid = sections[i].secid; li.appendChild(a); toc.appendChild(li); } container.parentNode.insertBefore(toc, container.parentNode.childNodes[0]); } addLoadEvent(tabbedsects);