如何使用按钮在新选项卡中打开

时间:2015-06-01 03:32:59

标签: javascript html css button tabs

<script type="text/html" id="marketSelection">
        <h3 class="choose-store">Choose your store:</h3>
        <div class="text-center">
            <% _.each(suppliers, function (supplier) { %>
            <button class="btn-custom supermarket-item" data-id="<%= supplier.id %>">
                <i></i><%= supplier.name %>
            </button>
            <% }) %>
        </div>

        /*File:src/js/data.js*/
        var cookie_selectedSupermarket = CookieManager.retrieve('supplierId'),
            cookie_selectedPostalCode = CookieManager.retrieve('deliveryareaCode'),
            cookie_q = CookieManager.retrieve('q');
        Data = {
            availabilityList: [JSON_STORE_AVAILABILITY_LIST],
            postalCodes: [JSON_POSTAL_CODES],

            hardCode: {
                selected_supermarket: null,
                selected_postal_code: null,
                q: null
            },
            query: {
                selected_supermarket: Utils.getQueryParameterByName('selected_supermarket'),
                selected_postal_code: Utils.getQueryParameterByName('selected_postal_code'),
                q: Utils.getQueryParameterByName('q')
            },
            cookie: {
                selected_supermarket: cookie_selectedSupermarket ? cookie_selectedSupermarket.value : null,
                selected_postal_code: cookie_selectedPostalCode ? cookie_selectedPostalCode.value : null,
                q: cookie_q ? cookie_q.value : null
            },

            PROTOCOL: 'https://',
            DOMAIN: 'www.test.com.au',
            PATH: '/',
            redirectURI: '/all-products/?supplier=<%= supplierId %><% if (q) { %>&q=<%= q %><% } %>'
        };

我在新标签页中打开按钮时遇到问题。在HTML中 - 我知道我们必须添加_blank但是对于这样的情况,解决方案是什么?

由于

编辑:添加更多代码,以便更清楚我想要的内容。

1 个答案:

答案 0 :(得分:1)

您可以使用Javascript

function openTab(url) {
  var win = window.open(url, '_blank');
  win.focus();
}