Floating X-menu

Source: Internet
Author: User
Tags border color tagname

<SCRIPT>
Function coolmenucontrol (){

File: // ----- regular variable ---

This. lastscrollx = 0;
This. lastscrolly = 0;
This. lastscrollw = 0;
This. lastscrollh = 0;
This. flsy = 0;
This. td_x = 0;
This. td_y = 0;
This. td_w = 0;
This. td_h = 0;
This. TD = 0;
This. My = 14;
This. mouseon = 0;
This. Current = NULL
This.hk _ name;
This. hktable_name;
This. menudiv_name;
This. menutable_name;
This. menuname;
This. ML = 0;
This. menuarray = new array ();
This. speed;
This. href = "";

File: // ----- menu item ---
Function menuitem (type, value, URL, target ){
This. type = Type
This. value = Value
This. url = URL
This.tar get = Target
}

File: // ----- Insert menu ---
This. insertmenu = function (type, value, URL, target ){
This. menuarray [This. menuarray. Length] = new menuitem (type, value, URL, target)
}

File: // ----- preliminary test of the program ---
This. init = function (name, BDC, BGC, speed, alpha ){
VaR inhtml = ""
VaR cellcount = 0
VaR lastcellcount = 0
This. menuname = Name
This.hk _ name = Name + "HK"
This. hktable_name = Name + "hktable"
This. menudiv_name = Name + "menudiv"
This. menutable_name = Name + "menutable"
This. speed = speed

For (I = 0; I <this. menuarray. length; I ++)
{
If (this. menuarray [I]. type = "2") cellcount = cellcount + 1
If (this. menuarray [I]. type = "1" | this. menuarray [I]. type = "0") {cellcount = 0}
If (lastcellcount <cellcount) {lastcellcount ++}

}

File: // alert (cellcount)

Stylecode = "cursor: hand; filter: alpha (style = 0, opacity =" + Alpha + "); background-color:" + BGC

Suspendcode = "<Div id =" + this.hk _ name + "style = 'position: absolute; Z-index: 3 'onclick = '" + name + ". doclick () '>"
+ "<Table id =" + this. hktable_name + "border = '1' width = '0' cellspacing = '0' style = 'border-collapse: Collapse 'bordercolor = '" + BDC + "'>"
+ "<Tr> <TD Height = '18' style = '" + stylecode + "'> </TD> </tr> </table> </div> ";
Document. Write (suspendcode );

VaR fcell = true
For (I = 0; I <this. menuarray. length; I ++)
{
Switch (this. menuarray [I]. type)
{
Case "0 ":
T = cellcount * 2
If (T <= 0)
{
Inhtml + = '<tr> <TD colspan = 2 class = HT onmouseover =/''+ name + '. href = "'{this.menuarray? I =.url=', '{this.menuarray= I }.tar get + '"/'> '+ this. menuarray [I]. value
}
Else
{
Inhtml + = '<tr> <TD colspan =' + T + 'class = HT onmouseover =/''+ name + '. href = "'{this.menuarray? I =.url=', '{this.menuarray= I }.tar get + '"/'> '+ this. menuarray [I]. value
}
Fcell = true
Break;
Case "1 ":
T = (cellcount-1) * 2
If (T <= 0)
{
Inhtml + = '<tr> <TD width = 6> <TD onmouseover =/''+ name + '. href = "'{this.menuarray? I =.url=', '{this.menuarray= I }.tar get + '"/'> '+ this. menuarray [I]. value
}
Else
{
Inhtml + = '<tr> <TD width = 6> <TD colspan =' + T + 'onmouseover =/'+ name + '. href = "'{this.menuarray? I =.url=', '{this.menuarray= I }.tar get + '"/'> '+ this. menuarray [I]. value
}
Fcell = true
Break;

Case "2 ":
If (fcell)
{
Inhtml + = '<tr> <TD width = 6> <TD onmouseover =/''+ name + '. href = "'{this.menuarray? I =.url=', '{this.menuarray= I }.tar get + '"/'> '+ this. menuarray [I]. value;
Fcell = false
}
Else
{
Inhtml + = '<TD width = 6> <TD onmouseover =/''+ name + '. href = "'{this.menuarray? I =.url=', '{this.menuarray= I }.tar get + '"/'> '+ this. menuarray [I]. value;
}
Break;
}
}
Inhtml = '<Div id =' + this. menudiv_name + 'onmousemove = "'+ name + '. doover () "style =" Right: 12px; position: absolute; top: 12px; Z-index: 2 ">'
+ '<Table id =' + this. menutable_name + 'border = "0" cellpadding = "2" class = "menu" cellspacing = "4">'
+ Inhtml
+ '</Table> </div> ';
File: // alert (inhtml)
Document. Write (inhtml );

This. lastscrollx = 0;
This. lastscrolly =-4;
This. posxy (eval (this. menutable_name). cells [0])
This. td_w = eval (this. menutable_name). cells [0]. scrollwidth + 6
This. td_h = eval (this. menutable_name). cells [0]. scrollheight
Setinterval (name + ". scrollback ()", 1)
}

File: // ----- click hyper-connect ---
This. doclick = function (){
File: // alert (this. url)
VaR url = This. href. Split (",")
File: // alert (URL [0])
File: // alert (URL [1])
If (URL [0] = "") Return

If (URL [1] = "_ blank ")
{Window. Open (URL [0])}
Else
{Location. href = URL [0]}
}

File: // ----- slide processing ---
This. scrollback = function (){
FY = Document. Body. scrolltop;
Diffx = This. td_X-3
Diffy = this. My
Diffw = This. td_w
Diffh = This. td_h

Percentx = This. Speed * (diffX-this.lastScrollX );
Percenty = This. Speed * (diffY-this.lastScrollY );
Percentw = This. Speed * (diffW-this.lastScrollW );
Percenth = This. Speed * (diffH-this.lastScrollH );
Percent =. 1 * (FY-this.FlsY );

If (percentx> 0) percentx = math. Ceil (percentx );
Else percentx = math. Floor (percentx );
If (percenty> 0) percenty = math. Ceil (percenty );
Else percenty = math. Floor (percenty );
If (percentw> 0) percentw = math. Ceil (percentw );
Else percentw = math. Floor (percentw );
If (percenth> 0) percenth = math. Ceil (percenth );
Else percenth = math. Floor (percenth );
If (percent> 0) percent = math. Ceil (percent );
Else percent = math. Floor (percent );

Eval (this.hk _ name). style. pixeltop + = percenty + percent;
Eval (this.hk _ name). style. pixelleft + = percentx;
Eval (this. hktable_name). style. pixelwidth + = percentw;
Eval (this. hktable_name). style. pixelheight + = percenth;
Eval (this. menudiv_name). style. pixeltop + = percent;

This. lastscrollx = This. lastscrollx + percentx;
This. lastscrolly = This. lastscrolly + percenty;
This. lastscrollw = This. lastscrollw + percentw;
This. lastscrollh = This. lastscrollh + percenth;
This. flsy = This. flsy + percent;
}

File: // ----- slide out ---
This. doover = function (){
If (event. srcelement. tagname = "TD "){
If (event. srcelement. innertext. Length = 0 | event. srcelement. innertext = "|") Return
This. posxy (event. srcelement)
This. td_w = event. srcelement. scrollwidth + 6
This. td_h = event. srcelement. scrollheight
This. My = This. td_Y-5-document.body.scrollTop
}
}

File: // ----- absolute positioning ---
This. posxy = function (OBJ ){
Hk_left = obj. offsetleft
Hk_top = obj. offsettop
Vparent = obj. offsetparent;

While (vparent. tagname. touppercase ()! = "Body ")
{
Hk_left + = vparent. offsetleft;
Hk_top + = vparent. offsettop;
Vparent = vparent. offsetparent;
}

This. td_x = hk_left
This. td_y = hk_top
}

File: // ----- about ---
This. About = function (){
Alert ("OK ")
}

}
</SCRIPT>

<Head>
<Meta http-equiv = "content-language" content = "ZH-CN">
<Style>
. B {color = #000066; cursor: hand}
. Menu {
Font-family: Arial;
Cursor: default;
Font-size: 12px;
Border: 1px #000000 solid;
Border-collapse: collapse;
Filter: progid: DXImageTransform. Microsoft. gradient (gradienttype = 0, startcolorstr = # ffffff, endcolorstr = # dddddddd)
Progid: DXImageTransform. Microsoft. Shadow (Direction = 135, color = # cccccc, strength = 3 );
}
. Ht {
Font-weight: bold
}
</Style>
<! --
Step 1: materialized X-menu class
Usage:
VaR <entity variable>. New coolmenucontrol ()
--->
<Script language = "JavaScript">
VaR coolmenu3 = new coolmenucontrol ()

VaR about = new array ()
About [0] = "for details about X-menu/n/nauthor: puterjam/ncopyright 2004/N, please notify me"
About [1] = "about the author/n/" This guy is very lazy, nothing left !! /"/N but welcome to talk with me JavaScript/nqq: 10644570/ne-mail: PuterJam@etang.com"

</SCRIPT>
</Head>
<Body>
<! --
Step 2: Create a menu project ---

Usage:
<Entity variable>. insertmenu (type, HTML code, link URL, target)
Type: 0 indicates the menu title, 1 indicates the tree menu sub-project, and 2 indicates the horizontal Menu Sub-project.
HTML code: HTML code displayed on the menu
Link URL: Needless to say, URL or Javascript script
Target: empty by default, which is not opened on this page; "_ blank" indicates opening on a new page
For example:
Coolmenu2.insertmenu ("2", " Sina", "http://www.sina.com.cn/", "_ blank ")
-->
<SCRIPT>

Coolmenu3.insertmenu ("0", " tree menu ","","")
Coolmenu3.insertmenu ("0", "Coolmenu3.insertmenu ("1", "about X-menu", "javascript: Alert (about [0])", "")
Coolmenu3.insertmenu ("1", "about Author", "javascript: Alert (about [1])", "")
Coolmenu3.insertmenu ("1", "Contact Me", "mailto: PuterJam@etang.com ","")
Coolmenu3.insertmenu ("1", "your browser version", "javascript: Alert (navigator. appname )","")
</SCRIPT>

<! --
Step 3: Create a menu ---

Usage:
<Object variable>. INIT (object variable name, border color, background color, sliding speed, and translucent background)
'Object variable name' must be the same as <object variable>
If the background color = "Transparent" is completely transparent
For example:
Coolmenu1.init ("coolmenu1", "#002000", "#38 ffff", 0.1, 15)
-->
<SCRIPT> coolmenu3.init ("coolmenu3", "#002000", "# f0ff00", 0.3, 25) </SCRIPT>
<SCRIPT>
For (I = 0; I <= 100; I ++)
{
Document. Write (I + "<br> ")
}
</SCRIPT>

 

</Body>
Click to download this file

From http://www.imting.com/puterjam/blogview.asp? Logid = 3 & cateid = 1

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.