How to implement a left-and-right menu on a control placed on a asp.net page and manipulate it (2)

Source: Internet
Author: User
Asp.net| Menu | controls | The page says the menu is created, and now it's Part two:

(2), select menu, click menu

Select the menu and click on the menu actually when the mouse MouseMove and click events. In the menustyle mentioned above, I implemented the pop-up menu with the Window.createpopup function provided by JavaScript, and the pop-up menu is a table. Each item in the table provides the MouseMove and click events.

I let him show a different style when the MouseMove incident happened.

When the Click event occurs, call the function Fnclick to make it happen to the task we need. Now to introduce the Menustyle () function.

function Menustyle () {

if (Window.navigator.appName = = "Microsoft Internet Explorer" && window.navigator.appVersion.substring ( Window.navigator.appVersion.indexOf ("MSIE") + 5, window.navigator.appVersion.indexOf ("MSIE") + 8) >= 5.5)

Isie = 1;

Else

Isie = 0;

if (Isie) {

menucontent = ' <table id= "rightmenu" width= "0" height= "0" cellspacing= "0" cellpadding= "0" style= "Font:menu;color: MenuText; " ><tr height= "1" ><td style= "Background:black" colspan= "4" ></td></tr><tr height= "10" &GT;&LT;TD style= "Background:black" ></td><td style= "Background:snow" ><table "0" cellpadding= "0" nowrap style= "Font:menu;color:menutext;cursor:default;" > '; This line is to draw a table, starting from below, add the items in the table, at the same time give the style of mouseover and so on. One of the most critical places is that the OnClick event occurs when the function called is Parent.fnclickmenu, with a special reminder that the function of the parent window is invoked.

for (m=0;m<menuitems.length;m++) {

if (Menuitems[m][0] && menuitems[m][2])

menucontent = ' <tr height= ' onmouseover= ' this.style.background=\ ' #9999cc \ '; this.style.color=\ ' menutext\ '; onmouseout= "This.style.background=\ ' snow\"; this.style.color=\ ' menutext\ '; "onclick=" parent.fnclickmenu (\ ' + menuitems[m][1]+ ' ")" <td style= "Background:threedface" width= "1" nowrap></td><td width= "nowrap" ></td><td nowrap> ' + menuitems[m][0] + ' &LT;/TD&GT;&LT;TD width= " "Nowrap></td><td style=" Background:threedface "width=" 1 "nowrap></td></tr>";

else if (menuitems[m][0])

menucontent = ' <tr height= ' onmouseover= ' this.style.background=\ ' #9999cc \ '; this.style.color=\ ' menutext\ '; onmouseout= "This.style.background=\ ' snow\"; this.style.color=\ ' menutext\ '; "onclick=" parent.fnclickmenu (\ ' + menuitems[m][1]+ ' \ ') "><td style=" Background:threedface "width=" 1 "nowrap></td><td width=" 21 " NOWRAP&GT;&LT;/TD&GT;&LT;TD nowrap> ' + menuitems[m][0] + ' </td><td width= ' nowrap></td><td Style= "Background:threedface" width= "1" nowrap></td></tr> ';

Else

Menucontent + + <tr><td colspan= "5" height= "4" &GT;&LT;/TD&GT;&LT;/TR&GT;&LT;TR&GT;&LT;TD colspan= "5" > <table cellspacing= "0" ><tr><td width= "2" height= "1" ></td><td width= "0" height= "1" style= " Background:threedshadow "></td><td width=" 2 "height=" 1 "></td></tr><tr><td Width= "2" height= "1" ></td><td width= "100%" height= "1" style= "Background:threedhighlight" ></td &GT;&LT;TD width= "2" height= "1" ></td></tr></table></td></tr><tr><td colspan= "5" height= "3" ></td></tr> ";

}

menucontent = ' </table></td><td style= ' Background:threedshadow "></td><td style=" Background:threeddarkshadow "></td></tr><tr height=" 1 "><td style=" background: Threedlightshadow "></td><td style=" background:threedhighlight "></td><td style=" Background:threedface "></td><td style=" Background:threedshadow "></td><td style=" Background:threeddarkshadow "></td></tr><tr height=" 1 "><td style=" background: Threedlightshadow "></td><td style=" Background:threedshadow "colspan=" 3 "></td><td style=" Background:threeddarkshadow "></td></tr><tr height=" 1 "><td style=" background: Threeddarkshadow "colspan=" 5 "></td></tr></table>";

A menu is popped up below.

Menupopup = Window.createpopup ();

The contents of the menu are the tables drawn above.

MenuPopup.document.body.innerHTML = menucontent;



Combined with the above ShowMenu (), the function, you can see how to implement the pop-up menu function method. In the Fnclickmenu function. You can easily add a variety of features that you want to deal with.

You reader, if you don't understand.
Vvvvvvvvvvv

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.