最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Javascript mailto function loading issue - Stack Overflow

programmeradmin1浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论