Is there a way I can open a new tab using inline javascript for the twitter tweet box. I tried placing target="_blank"
using inline javascript but it doesn't seem to work.
<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>
Use the target="_blank"
attribute in the anchor tag
<a href="your_url" target="_blank">Your Text</a>
And if you url is dynamic as in your case, call a funciton on click action and then using javascript, open a new tab.
<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();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.