Very good functions powerful code simple management menu simplified version

Source: Internet
Author: User

So excited... we found a backup file.
<Script type = "text/javascript">
Window. onload = function (){
Function $ (id) {return document. getElementById (id )}
Var menu = $ ("topTags"). getElementsByTagName ("ul") [0]; // top menu container
Var tags = menu. getElementsByTagName ("li"); // top menu
Var ck = $ ("leftMenu"). getElementsByTagName ("ul") [0]. getElementsByTagName ("li"); // left menu
Var j;
// Click the left-side menu to add a new tag.
For (I = 0; I <ck. length; I ++ ){
Ck [I]. onclick = function (){
$ ("Welcome"). style. display = "none" // hide the welcome content
ClearMenu ();
This. style. background = 'url (images/tabbg02.gif )'
// Obtain the current index cyclically
For (j = 0; j <8; j ++ ){
If (this = ck [j]) {
If ($ ("p" + j) = null ){
OpenNew (j, this. innerHTML); // sets the Label display text.
}
ClearStyle ();
$ ("P" + j). style. background = 'url (images/tabbg1.gif )';
ClearContent ();
$ ("C" + j). style. display = "block ";
}
}
Return false;
}
}
// Add or delete tags
Function openNew (id, name ){
Var tagMenu = document. createElement ("li ");
TagMenu. id = "p" + id;
TagMenu. innerHTML = name + "" + " ";
// Tag Click Event
TagMenu. onclick = function (evt ){
ClearMenu ();
Ck [id]. style. background = 'url (images/tabbg02.gif )'
ClearStyle ();
TagMenu. style. background = 'url (images/tabbg1.gif )';
ClearContent ();
$ ("C" + id). style. display = "block ";
}
// Close the image click event in the tag
TagMenu. getElementsByTagName ("img") [0]. onclick = function (evt ){
Evt = (evt )? Evt :( (window. event )? Window. event: null );
If (evt. stopPropagation) {evt. stopPropagation ()} // cancels the bubble action of opera and Safari;
This. parentNode. parentNode. removeChild (tagMenu); // Delete the current tag
Var color = tagMenu. style. backgroundColor;
// Set the focus of the last Tag if the tag is disabled.
If (color = "# ffff00" | color = "yellow") {// difference the browser's explanation of the color
If (tags. length-1> = 0 ){
ClearStyle ();
Tags [tags. length-1]. style. background = 'url (images/tabbg1.gif )';
ClearContent ();
Var cc = tags [tags. length-1]. id. split ("p ");
$ ("C" + cc [1]). style. display = "block ";
ClearMenu ();
Ck [cc [1]. style. background = 'url (images/tabbg1.gif )';
}
Else {
ClearContent ();
ClearMenu ();
$ ("Welcome"). style. display = "block"
}
}
}
Menu. appendChild (tagMenu );
}
// Clear the menu style
Function clearMenu (){
For (I = 0; I <ck. length; I ++ ){
Ck [I]. style. background = 'url (images/tabbg01.gif )';
}
}
// Clear the label Style
Function clearStyle (){
For (I = 0; I <tags. length; I ++ ){
Menu. getElementsByTagName ("li") [I]. style. background = 'url (images/tabbg2.gif )';
}
}
// Clear content
Function clearContent (){
For (I = 0; I <7; I ++ ){
$ ("C" + I). style. display = "none ";
}
}
}
</Script>

Online Demo http://www.jb51.net/jslib/EXTJS/code.htm
Package download
Imitation 163
Imitation 126

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.