[JavaScript] How to Create a menu like XP Explorer

Source: Internet
Author: User
Create an explorer menu similar to XP, as shown below:


The figure requires five figures:

The source code of the HTM file is as follows: if you need to add a menu, you can simply copy it, but you need to modify the red area.

<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en"

Http://www.w3.org/TR/html4/loose.dtd>

<HTML>

<Head>

<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">

<Title> one class explorer menu </title>

<Style type = "text/CSS">

<! --

. Group {

Font-family: "";

Font-size: 12px;

Background-image: URL (images/center.gif );

Height: 22px;

}

. Groupleft {

Background-image: URL (images/left.gif );

Height: 22px;

Width: 6px;

Background-repeat: No-repeat

}

. Groupright {

Background-image: URL (images/right.gif );

Height: 22px;

Width: 6px;

Background-repeat: No-repeat

}

. Menuitem {

Font-family: "";

Font-size: 12px;

Cursor: hand;

}

-->

</Style>

<Script language = "JavaScript">

VaR popupwin = 0;

Function popupwindow (urlstr, left, top, width, height)

{

If (popupwin)

{

If (! Popupwin. Closed) popupwin. Close ();

}

Popupwin = open (urlstr, 'popupwin', 'toolbar = No, location = No, directories = No, status = No, menub AR = No, scrollbar = No, resizable = No, copyhistory = Yes, width = '+ width +', Height = '+ height +', Left = '+ Left +', Top = '+ TOP + ', screenx = '+ Left +', screeny = '+ TOP + '');

}

Function messagewindow (title, MSG)

{

VaR width = "300", Height = "125 ";

VaR left = (screen. width/2)-width/2;

VaR Top = (screen. Height/2)-height/2;

VaR stylestr = 'toolbar = No, location = No, directories = No, status = No, menubar = No, scrollbar = No, resizable = No, copyhistory = Yes, width = '+ width +', Height = '+ height +', Left = '+ Left +', Top = '+ TOP +', screenx = '+ Left + ', screeny = '+ top;

VaR msgwindow = Window. Open ("", "msgwindow", stylestr );

VaR head = '
VaR body = '<center>' + MSG + '<br> <p> <form> <input type = "button" value = "done" onclick = "self. close () "> </form> ';

Msgw.domaindoc ument. Write (Head + body );

}

Function openmenu (menuid)

{

VaR OBJ = Document. getelementbyid ('menu '+ menuid );

VaR grpobj = Document. getelementbyid ('group' + menuid );

Current = (obj. style. Display = 'None ')? '': 'None ';

If (current = 'None ')

{

Grpobj. src = 'images/downarrows_white.gif ';

}

Else

Grpobj. src = 'images/uparrows_white.gif ';

OBJ. style. Display = current;

}

</SCRIPT>

</Head>

<Body>

<Table width = "150" border = "0" cellpadding = "0" cellspacing = "0">

<Tr>

<TD class = "groupleft"> </TD>

<TD width = "138" class = "group"> <Table width = "100%" Height = "100%" border = "0" cellpadding = "0" cellspacing = "0">

<Tr>

<TD width = "85%" Height = "21" ondblclick = "openmenu ('1')"> Data Query </TD>

<TD width = "15%"> </TD>

</Tr>

</Table> </TD>

<TD class = "groupright"> </TD>

</Tr>

<Tr id = "menu1" bgcolor = "# f0f0f0">

<TD> </TD>

<TD> <Div class = "menuitem">

<Li onmouseover = "this. style. color = '# ff9933' "onmouseout =" this. style. color = ''" onclick = "messagewindow ('hello', 'Are you OK? ') "> Query users </LI>

<Li onmouseover = "this. style. color = '# ff9933' "onmouseout =" this. style. color = ''" onclick = "popupwindow('index.htm', 800,600,)"> contract query </LI>

<Li onmouseover = "This. style. Color = '# ff9933'" onmouseout = "This. style. Color ='' "> prepayment query </LI>

<Li onmouseover = "This. style. Color = '# ff9933'" onmouseout = "This. style. Color ='' "> developer query </LI>

</Div>

</TD>

<TD> </TD>

</Tr>

<Tr>

<TD> </TD>

<TD> </TD>

<TD> </TD>

</Tr>

</Table>

</Body>

</Html>

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.