js实现鼠标右键菜单(弹出层),并与树形菜单(TreeView)、iframe合用

js实现鼠标右键菜单(弹出层),并与树形菜单(TreeView)、iframe合用
<table class="oa-el-panel-tree">
                    <tr>
                        <td style="vertical-align: top; width: 189px; position: relative" class="oa-el-panel-tree-line oa-el-panel-tree-view"
                            onmousedown="floatMenuClass.righthit(event)" oncontextmenu="return false">
                            <div id="divTreeView" style="overflow: auto; width: 189px; min-height: 350px;" class="oa-el-panel-tree-view">
                                <asp:TreeView ID="TreeViewFlowBase" runat="server" OnSelectedNodeChanged="TreeViewFlowBase_SelectedNodeChanged"
                                    ShowLines="True">
                                </asp:TreeView>
                                <input type="hidden" id="hidSelVal" runat="server" />
                                <div id="floatMenu">
                                    <ul>
                                        <li onclick="floatMenuClass.alter()">&nbsp;</li>
                                        <li onclick="floatMenuClass.add()">&nbsp;</li>
                                        <li onclick="floatMenuClass.reload()">&nbsp;</li>
                                        <li onclick="floatMenuClass.close()">&nbsp;</li>
                                    </ul>
                                </div>
                            </div>
                        </td>
                        <td style="vertical-align: top;" class="oa-el-panel-tree-line">
                            <div>
                                <iframe id="iframeOne" name="iframeOne" scrolling="auto" src="CurUser.aspx" width="900px"
                                    height="500px"></iframe>
                            </div>
                        </td>
                    </tr>
                </table>
js实现鼠标右键菜单(弹出层),并与树形菜单(TreeView)、iframe合用

 

js实现鼠标右键菜单(弹出层),并与树形菜单(TreeView)、iframe合用
<script type="text/javascript">
        /**2014-3-5 HY**/
        $(function () {
            setTimeout(function () {
                var w = $(window).width();
                var h = $(window).height();
                $(‘#iframeOne‘).animate({ height: h - 60 }, 500)
                $(‘#iframeOne‘).animate({ width: w - 212, height: h - 60 }, 500);
            }, 1);
        })
        $(window).resize(function () {
            setTimeout(function () {
                var w = $(window).width();
                var h = $(window).height();
                $(‘#iframeOne‘).animate({ height: h - 60 }, 500)
                $(‘#iframeOne‘).animate({ width: w - 212, height: h - 60 }, 500);
            }, 1);
        })

        var floatMenuClass =
        {
            objVal: null,
            objValRecord: null,
            righthit: function (event) {
                if (event.button == 2) {
                    var x = event.clientX;
                    var y = event.clientY;
                    $("#floatMenu").css({ left: x + "px", top: y + "px" });
                    if (!this.objVal) {
                        $("#floatMenu ul li:first").hide();
                    }
                    else {
                        if ($("#floatMenu ul li:first").is(":hidden")) {
                            $("#floatMenu ul li:first").show();
                        }
                    }
                    this.open();
                }
            },
            reload: function () {
                location.href = "The_title_manage.aspx";
            },
            close: function () {
                $("#floatMenu").hide(200);
            },
            open: function () {
                $("#floatMenu").show(200);
            },
            alter: function () {
                var txt = encodeURIComponent($(this.objValRecord).text());
                this.gotoWin("the_title_Edit.aspx?sub=" + $("#hidSelVal").val() + "&depart=" + txt);
                //$(this.objVal).click();
                this.close();
            },
            add: function () {
                this.gotoWin("the_title_Edit.aspx");
                this.close();
            },
            gotoWin: function (strUrl) {
                var a = document.createElement("a");
                a.setAttribute("href", strUrl);
                a.style.display = "none";
                a.setAttribute("target", "iframeOne");
                document.body.appendChild(a);
                if (document.all) {
                    a.click();
                }
                else {
                    var evt = document.createEvent("MouseEvents");
                    evt.initEvent("click", true, true);
                    a.dispatchEvent(evt);
                }
            },
            init: $(function () {
                $("a[id]", $("#TreeViewFlowBase")).hover(
                function () {
                    floatMenuClass.objVal = this;
                    floatMenuClass.objValRecord = this;
                },
                 function () {
                     floatMenuClass.objVal = null;
                 });
            })
        }
    </script>
js实现鼠标右键菜单(弹出层),并与树形菜单(TreeView)、iframe合用
js实现鼠标右键菜单(弹出层),并与树形菜单(TreeView)、iframe合用
 /// <summary>
    /// 加载树信息
    /// </summary>
    public void LoadTree(string ids)
    {
        TreeViewFlowBase.Nodes.Clear();
        BLL.the_title tt = new BLL.the_title();
        BLL.Sys_cur_user user = new BLL.Sys_cur_user();

        DataTable dtbt = tt.GetList("substoreid=‘" + ids + "");
        DataSet ds = user.GetAllList("substoreid=‘" + ids + "");
        if (dtbt != null)
        {
            foreach (DataRow row in dtbt.Select("", "the_sort desc"))
            {
                TreeNode tn = new TreeNode();
                tn.Text = row["the_name"].ToString();
                tn.Value = row["substoreid"].ToString();
                tn.ToolTip = "职称";

                tn.ImageUrl = "~/images/list_dbsy.gif";
                tn.Target = "iframeOne";
                tn.NavigateUrl = "the_title_Edit.aspx?sub=" + row["substoreid"].ToString() + "&depart=" + Server.UrlEncode(row["the_name"].ToString());

                foreach (DataRow dr in ds.Tables[0].Select("depart=‘" + row["the_name"].ToString() + ""))
                {
                    TreeNode tnChild = new TreeNode();
                    tnChild.Text = dr["user_name"].ToString();
                    tnChild.Value = dr["user_code"].ToString();
                    tnChild.ToolTip = "员工";

                    tnChild.ImageUrl = "~/images/list_zxxx.gif";
                    //设置子节点不能点击
                    tnChild.SelectAction = TreeNodeSelectAction.None;
                    tn.ChildNodes.Add(tnChild);
                }

                TreeViewFlowBase.Nodes.Add(tn);
            }
        }
    }
js实现鼠标右键菜单(弹出层),并与树形菜单(TreeView)、iframe合用

js实现鼠标右键菜单(弹出层),并与树形菜单(TreeView)、iframe合用,布布扣,bubuko.com

js实现鼠标右键菜单(弹出层),并与树形菜单(TreeView)、iframe合用

上一篇:Markdown语法


下一篇:Win7、win2008中让IIS7支持asp的方法