简体   繁体   English

如何使用表中的上下文菜单打开新选项卡

[英]how to open a new tab using context menu in a table

在此处输入图片说明 I am using a datatable to show some data and using context menu to navigate to another page from the datatable.But the problem is that when i am clicking the context menu tab the new window is opening in the same tab.but i need to open it in another tab,but it is not happening.I am giving the code .. 我正在使用一个数据表显示一些数据,并使用上下文菜单从该数据表导航到另一页。但是问题是当我单击上下文菜单选项卡时,新窗口正在同一选项卡中打开,但是我需要打开它在另一个选项卡中,但没有发生。我正在提供代码..

<script type="text/javascript" class="showcase">
            $(function() {
                var selectedVal;
                $.contextMenu({
                    selector : '.context-menu-one',
                    callback : function(key, options) {
                        var row = options.$trigger;
                        var newUrl = key;

                        if (key === 'calllist.do') {
                            var rows = row.find("td").eq(2).html();
                            actionUrl = '?' + 'a_no='
                                    + rows.toLocaleString();
                        }
                        if (key === 'travel') {
                            var rows = row.find("td").eq(3).html();
                            actionUrl = '?' + 'a_no='
                                    + rows.toLocaleString();
                        }
                        if (key === 'call_usage') {
                            var rows = row.find("td").eq(3).html();
                            actionUrl = '?' + 'a_no='
                                    + rows.toLocaleString();
                        }
                        if (key === 'network_analysis') {
                            var rows = row.find("td").eq(3).html();
                            actionUrl = '?' + 'a_no='
                                    + rows.toLocaleString();
                        }
                        if (key === 'location_analysis.do') {
                            var rows = row.find("td").eq(3).html();
                            actionUrl = '?' + 'a_no='
                                    + rows.toLocaleString();
                        }

                        if (key === 'location_tracker.do') {
                            var rows = row.find("td").eq(3).html();
                            actionUrl = '?' + 'a_no='
                                    + rows.toLocaleString();
                        }

                        if (key === 'personal') {
                            var rows = row.find("td").eq(1).html();
                            actionUrl = '?' + 'a_no='
                                    + rows.toLocaleString();
                            //  alert(actionUrl);

                        }

                        if (key === 'newsim.do') {
                            var rows = row.find("td").eq(5).html();
                            actionUrl = '?' + 'a_no='
                                    + rows.toLocaleString();
                            //  alert(actionUrl);

                        }

                        if (key === 'analyzecallingno') {
                            var rows = row.find("td").eq(2).html();
                            actionUrl = '?' + 'a_no='
                                    + rows.toLocaleString();


                        }

                        if (key === 'simdensity.do') {
                            var rows = row.find("td").eq(5).html();
                            actionUrl = '?' + 'a_no='
                                    + rows.toLocaleString();


                        }

                        document.forms[0].action = newUrl + actionUrl;
                        document.forms[0].submit();
                    },
                    items : {

                        "analyzecallingno" : {
                            name : "Analyze Calling Number"
                        },
                        "travel": {
                            name : "Analyze Caller Tower"
                        },
                        "network_analysis" : {
                            name : "Social Network Analysis"
                        },
                        "call_usage" : {
                            name : "Call Analysis Summary"
                        },
                        "location_tracker.do" : {
                            name : "Location Tracking"
                        },
                        "personal" : {
                            name : "Caller Personal Details"
                        }

                    }
                });
            });
        </script>

        <table class="tableData context-menu-one" id="tableData"
            style="overflow-x: scroll">
            <thead>
                <tr style="font-size: 14px;">
                    <th align="left">CALLTYPE</th>
                    <th align="left">CALLER</th>
                    <th align="left">CALLEE</th>
                    <th align="left">DURATION</th>
                    <th align="left">START DATE</th>
                    <th align="left">END DATE</th>
                    <th align="left">FROM LOC</th>
                    <th align="left">TO LOC</th>
                    <th align="left">IMEI</th>
                    <th align="left">IMSI</th>
                </tr>
            </thead>
            <tbody>
                <c:forEach items="${searchpage}" var="listofvalues">
                    <tr class="context-menu-one notfirst" style="font-size: 12px;">
                        <td align="left"><c:out value="${listofvalues.call_type}" /></td>
                        <td align="left"><c:out value="${listofvalues.a_no}" /></td>
                        <td align="left"><c:out value="${listofvalues.b_no}" /></td>
                        <td align="left"><c:out
                                value="${listofvalues.call_duration}" /></td>
                        <td align="left"><c:out value="${listofvalues.start_day}" /></td>
                        <td align="left"><c:out value="${listofvalues.end_day}" /></td>
                        <td align="left"><c:out
                                value="${listofvalues.a_home_circle}" /></td>
                        <td align="left"><c:out
                                value="${listofvalues.a_rome_circle}" /></td>
                        <td align="left"><c:out value="${listofvalues.a_imei}" /></td>
                        <td align="left"><c:out value="${listofvalues.a_imsi}" /></td>

                    </tr>
                </c:forEach>
            </tbody>
        </table>
    </div>
</div>

在此处输入图片说明

Maybe you could use something like $("form:first").attr('target', '_blank').submit(); 也许您可以使用$("form:first").attr('target', '_blank').submit(); instead of document.forms[0].action = newUrl + actionUrl; 而不是document.forms[0].action = newUrl + actionUrl; .

ps. ps。 don't forget to set your action URL: 不要忘记设置您的操作网址:

$("form:first").attr({
                      'target':'_blank',
                      'action':newUrl + actionUrl
                    }).submit();

You could also use $( "form" ).first().attr.... . 您也可以使用$( "form" ).first().attr....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以使用javascript捕获“在新标签中打开”单击上下文菜单的事件? - Is it possible to capture “Open in New Tab” clicked event of context menu using javascript? 从 Chrome 扩展上下文菜单打开新标签页 - Open new tab from Chrome Extension Context Menu 如何在新选项卡中打开特定的菜单div - How to open particular menu div in a new tab javascript:如何检查是否在上下文菜单的新选项卡上单击了链接 - javascript: How to check if a link is clicked over context menu new tab 如何使用适当的角度路由以角度打开新选项卡中的mat-menu-item? - How to open mat-menu-item in a new tab in angular using proper angular routing? 右键单击上下文菜单<div>像锚(打开新标签等) - Right click context menu for <div> like anchor (open new tab etc..) 标记 HTML 以允许右键单击上下文菜单中的“在新选项卡中打开”选项的正确方法 - Proper way to mark up HTML to allow for right click “open in a new tab” option in context menu 如何使用按钮在新标签页中打开 - How to open in new tab using button 如何使用javascript在新标签页中打开链接 - How to open a link in new tab using javascript 如何使用 Playwright 打开新选项卡(例如单击按钮在新选项卡中打开新部分) - How to open the new tab using Playwright (ex. click the button to open the new section in a new tab)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM