I'm nidhin
I'm nidhin

Reputation: 2662

Javascript mailto function loading issue

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;
}

Upvotes: 1

Views: 6212

Answers (2)

hgolov
hgolov

Reputation: 722

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.

Upvotes: 0

Nikola K.
Nikola K.

Reputation: 7155

Use window.open function.

window.open('mailto:[email protected]?subject='+code, '_blank')

Read more here.

Upvotes: 4

Related Questions