簡體   English   中英

使用內聯JavaScript打開新標簽頁

[英]Open a new tab using inline javascript

有沒有一種方法可以使用Twitter推文框的嵌入式javascript打開新選項卡。 我嘗試使用嵌入式JavaScript放置target="_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="_blank"屬性

<a href="your_url" target="_blank">Your Text</a>

如果您的網址是動態的,請在點擊操作中調用函數,然后使用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();
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM