使用内联javascript打开新选项卡
有没有一种方法可以使用内联javascript为twitter推文框打开一个新选项卡。我尝试使用内联javascript放置使用内联javascript打开新选项卡,javascript,jquery,Javascript,Jquery,有没有一种方法可以使用内联javascript为twitter推文框打开一个新选项卡。我尝试使用内联javascript放置target=“\u blank”,但似乎不起作用 <a id="twitter" onclick ="window.location.href='https://twitter.com/intent/tweet?text=Electric Studio Referral Code: ' + document.getElementById('input-refcode
target=“\u blank”
,但似乎不起作用
<a id="twitter" onclick ="window.location.href='https://twitter.com/intent/tweet?text=Electric Studio Referral Code: ' + document.getElementById('input-refcode').value + ' https://www.electricstudio.ph/' " target="_blank"></a>
使用锚定标记中的target=“\u blank”
属性
<a href="your_url" target="_blank">Your Text</a>
如果您的url是动态的,就像您的例子一样,那么在单击操作时调用一个函数,然后使用javascript打开一个新选项卡
<a onClick="openTab()>Your Text</a>
function openTab(url) {
var url = 'https://twitter.com/intent/tweet?text=Electric Studio Referral Code: ' + document.getElementById('input-refcode').value + ' https://www.electricstudio.ph/';
var win = window.open(url, '_blank');
win.focus();
}