Features:
Better appearance: added icon on menu title.
Better actions: Implemented menu sliding in and sliding out effects.
Easier to use: Many comments have been added for easy use.
Of course there are still some undiscovered problems. I hope you can give me some advice:)
Implementing a foldable dynamically changing the value of style.height. This is not very professional:) But it looks very similar!
100% original winXP collapsible menu appearance! If it's different, please tell me and I'll change it.
(qq2006 still has some jitters when clicking.)
Look at the picture first. The latest addition The appearance of qq2006
Test webpage address: navbar.htm
Detailed URL: http://lxbzj.com/showartical.asp?N_id=156
Download: http://lxbzj.com/upload/200604/menu.zip
The new version is still in production. . . (The updated js is on layer 19)
Here is the js modified on 2006-04-13
- It is no longer necessary to add onclick and onkeypress to each This way, the web page and js are further separated
-Define a menu class responsible for adding events to each menu
-Modify onkeypress
-Add interval processing
-Add a retracting acceleration (but not very obvious)
-Added Navbar object, so that only one menu can be opened in a group
-New js is constantly being updated. . .
- Code in navbar.js:
// JavaScript Document
/*==================================== =====
* File name: navbar.js
* Encoding: Utf-8
* Function: javaScript to implement menu folding
* Author: Lei Xiaobao
* Version: 2.3
* Time: 2006-03-07
============================== =============*/
//==========================Define menu class=== ===============;
function Menu(head,child,dir,speed,init_state,ext_on,ext_off)
{
this.head = document.getElementById (head);//Menu header
this.body = document.getElementById(child);//Menu body
this.direction = dir;//Menu retracting direction
this.speed = speed ;//Speed
this.ext_on = ext_on;//Extended menu expansion call
this.ext_off = ext_off;//Extended menu collapse call
this.init_state = init_state;//Initial setting of menu State true/false
this.a = 10;//Acceleration
//Private variable;
this._interval = false;
this._last_state = false;
this._size = false;
this._temp = false;
this._js = false;
this._div = false;
this._parent = false;
this._parent_control = false;
var self = this;
var temp = new Array(null,null);//temp[0] is used for _off(), temp[1] is used for _on()
//==============================Method================ =============
//Click event processing
this.click = function(e)
{
if (self._parent_control)
{ if (self._last_state = = false)
🎜> 🎜> 🎜> this.head.onkeypress = function(e)
{
e||(e=window.event);
if (!(e.keyCode ==32 || e.keyCode == 0) )return;
//alert(':)');
for(var i=0;i
if (this.body.childNodes[i].nodeType==1)
{
this._div=this.body.childNodes[i];
break;
}
}
if (parseInt(this.body.style.height))//this.body.style.getPropertyCSSValue('height')this.body.currentStyle.height
{
this._size = parseInt(this.body.style.height);
}
else
{
this._size = this._div.offsetHeight;
}
switch (this.init_state)
{
case true:
if (this.body.style.display == 'none')
{
//this._last_state = false;
this._on();
}
else
{
this._last_state = true;
}
break;
default://case false:
if (this.body.style.display !='none')
{
this._last_state = true;
this._off();
}
break;
}
}
//展开菜单
this._on = function()
{
if (self._last_state == false)
{
self._last_state = true;
self.body.style.display="";
temp[1] = self.a?2*parseInt(Math.sqrt(self.a*self._size)) 1:self._size/5;
if (isNaN(parseInt(self.body.style.height)))self.body.style.height="0px";
if (self.ext_on)
{
self.ext_on(self.head,self.body)
}
self._interval = Interval.set(self._action_on,speed);
}
//setTimeout('slowon("' self.body.id '")',5)
}
//收起菜单
this._off = function()
{
if (self._last_state == true)
{
self._last_state = false;
//if (temp[0] == null)
//{
temp[0]=self.a?2*parseInt(Math.sqrt(self.a*self._size)) 1:self._size/5;;
//}
if(isNaN(parseInt(self.body.style.height)))self.body.style.height = self._size 'px';
if (self.ext_off)
{
self.ext_off(self.head,self.body)
}
self._interval = Interval.set(self._action_off,this.speed);
}
}
//以下处理滑动
this._action_on = function()
{
if (parseInt(self.body.style.height) temp[1]>self._size)
{
self.body.style.height = self._size 'px';
Interval.clear(self._interval);
}
else
{
self.body.style.height = parseInt(self.body.style.height) temp[1] 'px';
temp[1] =self.a;
}
}
this._action_off = function()
{
if(parseInt(self.body.style.height)-temp[0] {
Interval.clear(self._interval);
self.body.style.display = "none";
}
else
{
self.body.style.height = parseInt(self.body.style.height)-temp[0] 'px';
temp[0]-=self.a ;
}
}
}
//End of meanu class
//====================Definition Navbar class, used to manage a set of menu collections ================================
function navbar(dir,a ,speed,ext_on,ext_off)
{
this.open_only_one = true;//Whether only one menu of this group is open at any time, true/false
this.dir = dir;//menu group public direction. Since it is a group of menus, they should have the same direction, right?
this.a =a;//menu Public acceleration
this.speed =speed;//Public speed
this.ext_on = ext_on;//Public extension open function call
this.ext_off = ext_off;//Public extension collapse function call
this.menu_item = new Array();//menu group
this._openning;//If only one menu is allowed to be opened, this will record the currently opened one Menu
this.open_all = function()//
{
};
this.add = function (head,body)//Function to add menu
{
var temp = new Menu(head,body,this.dir,this.speed,this.ext_on,this.ext_off);
this.menu_item.push(temp);
};
this.init = function ()//Navbar’s initialization function must be called after add is completed.
{
if(this.open_only_one == true)
A menu is open
if (this.menu_item.length>0)
{
with(this.menu_item[0])
🎜> init_state = true;
_parent = this;//Set the father of the menu as this Navbar
_parent_control = true;//Set the parent to control the menu
init();
} }
This._openning = this.menu_item[0] ;
through > 🎜> init();
}
else
{//If open_only_one == false then only initialize the menu
for(var i = 0;i
this.menu_item.init();
;
//Additional parent control function
this._control = function(child)
{
var self =child;
Interval.clear(self._interval);
if (self._last_state == false)
._openning._off();
self._parent. }
else
{
//self._off( );
return false; ====================interval processing============================ =
//Note: _stack only has 20 items
//When expanding, an initial value of 1-n must be assigned
Interval=
{
length:20,
_action: new Array( length),
_stack : new Array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 ),
_interval : Array(length),
_timeout: new Array(length),
//for(var i=0;i<_action.length> set:function(action_function,speed,time_out)
{
time_out = time_out?time_out:15000;//The default interval timeout is 15000 seconds. If you do not need to set a timeout, then setTimeout below Then comment out the line; val._interval[p ]=setInterval('if(Interval._action[' p '])Interval._action[' p ']();',speed);//The repeated execution function here cannot be written as 'Interval._action[' p '] 'Because it is very likely that after Interval.clear, there will be another execution that has not been completed, so an error occurred
Interval._timeout[p] Interval.clear(' p ')', time_out); // This line sets the interval timeout, you can comment it out if you don’t need it;
; p])
🎜> Interval._action[p] = "";
Interval._stack.push(p);
}
}
}
//Interval processing ends

The main difference between Python and JavaScript is the type system and application scenarios. 1. Python uses dynamic types, suitable for scientific computing and data analysis. 2. JavaScript adopts weak types and is widely used in front-end and full-stack development. The two have their own advantages in asynchronous programming and performance optimization, and should be decided according to project requirements when choosing.

Whether to choose Python or JavaScript depends on the project type: 1) Choose Python for data science and automation tasks; 2) Choose JavaScript for front-end and full-stack development. Python is favored for its powerful library in data processing and automation, while JavaScript is indispensable for its advantages in web interaction and full-stack development.

Python and JavaScript each have their own advantages, and the choice depends on project needs and personal preferences. 1. Python is easy to learn, with concise syntax, suitable for data science and back-end development, but has a slow execution speed. 2. JavaScript is everywhere in front-end development and has strong asynchronous programming capabilities. Node.js makes it suitable for full-stack development, but the syntax may be complex and error-prone.

JavaScriptisnotbuiltonCorC ;it'saninterpretedlanguagethatrunsonenginesoftenwritteninC .1)JavaScriptwasdesignedasalightweight,interpretedlanguageforwebbrowsers.2)EnginesevolvedfromsimpleinterpreterstoJITcompilers,typicallyinC ,improvingperformance.

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.

The power of the JavaScript framework lies in simplifying development, improving user experience and application performance. When choosing a framework, consider: 1. Project size and complexity, 2. Team experience, 3. Ecosystem and community support.

Introduction I know you may find it strange, what exactly does JavaScript, C and browser have to do? They seem to be unrelated, but in fact, they play a very important role in modern web development. Today we will discuss the close connection between these three. Through this article, you will learn how JavaScript runs in the browser, the role of C in the browser engine, and how they work together to drive rendering and interaction of web pages. We all know the relationship between JavaScript and browser. JavaScript is the core language of front-end development. It runs directly in the browser, making web pages vivid and interesting. Have you ever wondered why JavaScr


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
