How to prevent mailto event from opening a new tab in browser

后端 未结 8 1600
一个人的身影
一个人的身影 2021-02-05 02:36

I am using a mailto: filled in JavaScript to send information throughout my web application, but everytime a user presses the Send button, it opens a new t

8条回答
  •  不知归路
    2021-02-05 03:04

    Thank you for the edit. There is indeed an alternative:

    window.location.href = "mailto:mail@domain.tld";
    alert("Thank you!");
    

    I don't want to use window.location.href since I am displaying a message after the user sent the email.

    I did not really get this one. You are not leaving the website when using mailto: with window.location.href

提交回复
热议问题