To the right of the bootstrap menu plus right close

<ul class="rightmenu">
        <li data-type="closethis">关闭当前</li>
        <li data-type="closeall">关闭所有</li>
        <li data-type="closemenu">关闭菜单</li>
    </ul>

First attach html code right pop-up menu

 <script type="text/javascript">
        $('.rightmenu').hide();
        $(document).click(function () {
            $('.rightmenu').hide();
        })
        $("#lr_frame_tabs_ul").on("contextmenu",function(e){
             var popupmenu = $(".rightmenu");
                l = ($(document).width() - e.clientX) < popupmenu.width() ? (e.clientX - popupmenu.width()) : e.clientX;
                t = ($(document).height() - e.clientY) < popupmenu.height() ? (e.clientY - popupmenu.height()) : e.clientY;
                popupmenu.css({left: l, top: t}).show();
                return false;
        })
        
        $(".rightmenu li").click(function () {
            if ($(this).attr("data-type") == "closethis") {
                var tabid = $("li[class='wms-frame-tabItem active']").attr('id').substr(7);// 获取当前激活的选项卡ID
                debugger
                top.robo.frameTab.close(tabid);
            } else if ($(this).attr("data-type") == "closeall") {
                var tabtitle = $(".wms-frame-tabItem");
                var ids = new Array();
                $.each(tabtitle, function (i) {
                    ids[i] = $(this).attr("id").substr(7);
                    if (ids[i] != "0")
                        top.robo.frameTab.close(ids[i]);
                })

            } else if ($(this).attr("data-type") == "closemenu") {
                $('.rightmenu').hide();
            }
            $('.rightmenu').hide();
        })
        
    </script>

Then attach up js code, a little explanation of when to start loading the default menu should be hidden, right-click menu function is triggered on binding contextmenu.

Finally renderings! ! !

 

Guess you like

Origin www.cnblogs.com/AndyLin/p/11425172.html