admin管理员组

文章数量:1023773

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
Add a ment  | 

2 Answers 2

Reset to default 4

Use 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.

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
Add a ment  | 

2 Answers 2

Reset to default 4

Use 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.

本文标签: Javascript mailto function loading issueStack Overflow