-6ren">
gpt4 book ai didi

javascript - 如何使用按钮在新标签页中打开

转载 作者:太空宇宙 更新时间:2023-11-04 11:51:58 28 4
gpt4 key购买 nike

<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 但对于这种情况,解决方案是什么?

谢谢

编辑:添加了更多代码,以便更清楚我想要什么。

最佳答案

你可以使用Javascript

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

关于javascript - 如何使用按钮在新标签页中打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30565273/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com