I'm using JavaScript mailto
function and when clicking on the button the mail loads in the same tab. How can I load the mail in a new tab?
Here's my code:
<input type="button" value="Apply" name="apply" onclick="mailJob('Sample');">
function mailJob(code)
{
window.location="mailto:[email protected]?subject="+code;
}
I'm using JavaScript mailto
function and when clicking on the button the mail loads in the same tab. How can I load the mail in a new tab?
Here's my code:
<input type="button" value="Apply" name="apply" onclick="mailJob('Sample');">
function mailJob(code)
{
window.location="mailto:[email protected]?subject="+code;
}
Share
Improve this question
edited Jul 21, 2012 at 19:26
Nikola K.
7,15513 gold badges32 silver badges39 bronze badges
asked Jul 21, 2012 at 19:17
I'm nidhinI'm nidhin
2,6726 gold badges39 silver badges65 bronze badges
1
- read here: stackoverflow./questions/5141910/… – Yan Berk Commented Jul 21, 2012 at 19:18
2 Answers
Reset to default 4Use window.open
function.
window.open('mailto:[email protected]?subject='+code, '_blank')
Read more here.
window.location will redirect the current page to the indicated url. In order to open a new window or tab, you need to do window.open, as is shown in answer that Yan linked to.