新标签页中的 whmcs 发票

whmcs invoice in new tab

我想在新标签页或弹出窗口中打开 whmcs 的发票 window。 这个问题的最大部分已经解决,但还有一件事仍然是一个问题。我使用一些 js 在新选项卡中打开发票,但在原始页面上,打开发票后,它还会加载 returns 404。发票打开没有任何问题。

这是js

            <script>
            function OpenInNewTab(url) {
                var win = window.open(url, '_blank');
                win.focus();
                 }
            </script>

这是调用发票并将其显示在 table 中的代码。注意:这是一个聪明的.tpl

<tr onclick="clickableSafeRedirect(event, OpenInNewTab('viewinvoice.php?id={$invoice.id}'), false)">
                    <td>{$invoice.invoicenum}</td>
                    <td><span class="hidden">{$invoice.normalisedDateCreated}</span>{$invoice.datecreated}</td>
                    <td><span class="hidden">{$invoice.normalisedDateDue}</span>{$invoice.datedue}</td>
                    <td>{$invoice.total}</td>
                    <td><span class="label status status-{$invoice.statusClass}">{$invoice.status}</span></td>
                    <td class="responsive-edit-button" style="display: none;" >
                        <a href="viewinvoice.php?id={$invoice.id}" class="btn btn-block btn-info" >
                            {$LANG.manageproduct}
                        </a>
                    </td>
                </tr>

我在这一行添加了 OpenInNewTab

<tr onclick="clickableSafeRedirect(event, OpenInNewTab('viewinvoice.php?id={$invoice.id}'), false)">

这是原始代码

<tr onclick="clickableSafeRedirect(event, viewinvoice.php?id={$invoice.id}, false)">

提前致谢!!

编辑:我尝试将 clickableSafeRedirect 函数与 OpenInNewTab 函数合并,这导致在原始页面上加载发票的空白选项卡。

这是 clickableSafeRedirect 函数

function clickableSafeRedirect(clickEvent, target, newWindow) {

    var eventSource = clickEvent.target.tagName.toLowerCase();
    var eventParent = clickEvent.target.parentNode.tagName.toLowerCase();
    var eventTable = clickEvent.target.parentNode.parentNode.parentNode;
    if (jQuery(eventTable).hasClass('collapsed')) {
        // This is a mobile device sized display, and datatables has triggered folding
        return false;
    }
    if(eventSource != 'button' && eventSource != 'a') {
        if(eventParent != 'button' && eventParent != 'a') {
            if (newWindow) {
                window.open(target);

            } else {
                window.location.href = target;

            }
        }
    }
}

WHMCS 中的此函数 clickableSafeRedirect() 有一个参数,允许您打开新的 window 而不是您的自定义函数。

删除您的 OpenInNewTab() 函数并使其成为:

clickableSafeRedirect(event, viewinvoice.php?id={$invoice.id}, true);
---------------------------------------------------------------^^^^

在新打开的第三个参数中设置为真window。查看whmcs中的代码。函数的定义是:

function clickableSafeRedirect(clickEvent, target, newWindow)