Categories
JavaScript Answers

How to add mailto link using JavaScript?

Spread the love

Sometimes, we want to add mailto link using JavaScript.

In this article, we’ll look at how to add mailto link using JavaScript.

How to add mailto link using JavaScript?

To add mailto link using JavaScript, we set the window.location.href value.

For instance, we write

window.location.href = "mailto:mail@example.org";

to set window.location.href to "mailto:mail@example.org" to open the default email client with the to field set to mail@example.org.

Conclusion

To add mailto link using JavaScript, we set the window.location.href value.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *