zoukankan      html  css  js  c++  java
  • 可定制的IE鼠标右键菜单

    using System;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using System.Drawing;

    [assembly:TagPrefix("MyWebMenu","zbjg")]
    namespace MyTools
    {
        /// <summary>
        /// Summary description for MyWebMenu.
        /// </summary>
        public class MyWebMenu : System.Web.UI.WebControls.Panel
        {
            public MyWebMenu()
            {
                this.BorderStyle = BorderStyle.Outset;
                this.BackColor = Color.Silver;
                this.BorderWidth= new Unit(2);
            }

            protected override void Render(HtmlTextWriter writer)
            {
                base.Render (writer);
                writer.RenderBeginTag(HtmlTextWriterTag.Script);
                writer.WriteLine("<!--");
                writer.WriteLine("   document.getElementById('" + this.ClientID + "').style.position = 'absolute';");
                writer.WriteLine("   document.getElementById('" + this.ClientID + "').style.display = 'none';");
                writer.WriteLine("   function Hide_MyMenu() {");
                writer.WriteLine("      var tempDiv = document.getElementById('" + this.ClientID + "');");
                writer.WriteLine("      if(tempDiv.offsetLeft > window.event.clientX + 25) {");
                writer.WriteLine("         tempDiv.style.display = 'none'; }");
                writer.WriteLine("      if(tempDiv.offsetLeft + tempDiv.offsetWidth < window.event.clientY - 25) {");
                writer.WriteLine("         tempDiv.style.display = 'none'; }");
                writer.WriteLine("      if(tempDiv.offsetTop > window.event.clientY + 25) {");
                writer.WriteLine("         tempDiv.style.display = 'none'; }");
                writer.WriteLine("      if(tempDiv.offsetTop + tempDiv.offsetHeight < window.event.clientY - 25) {");
                writer.WriteLine("         tempDiv.style.display = 'none'; }");
                writer.WriteLine("   }");
                writer.WriteLine("");

                writer.WriteLine("   function Show_MyMenu() {");
                writer.WriteLine("      var tempDiv = document.getElementById('" + this.ClientID + "');");
                writer.WriteLine("      tempDiv.style.left = window.event.clientX ;");
                writer.WriteLine("      tempDiv.style.top = window.event.clientY ;");
                writer.WriteLine("      tempDiv.style.display = '' ;");
                writer.WriteLine("      return false; }");
                writer.WriteLine("");
                writer.WriteLine("   document.oncontextmenu = Show_MyMenu;");
                writer.WriteLine("   document.onmousemove = Hide_MyMenu;");
                writer.WriteLine("//-->");
                writer.RenderEndTag();
            }

        }
    }
  • 相关阅读:
    2017——我们为什么选择JAVA?JAVA的发展方向和学习方法(必看)
    Java
    4中引用(强,软,弱,虚)侧重弱引用
    面试常见问题
    一个牛人给java初学者的建议
    java转换图片压缩生成webp格式
    JVM-String常量池与运行时常量池
    轮滑基础(一)(前摔,葫芦步,推步,A字转弯,弓步转弯)
    单词本
    可空值 DateTime? ToString("yy-MM-dd")
  • 原文地址:https://www.cnblogs.com/zhuor/p/282817.html
Copyright © 2011-2022 走看看