Javascript Browser Location href Property set email url

Introduction

Set the href value to point to an email address:

location.href = "mailto:someone@example.com";

Click the button to set the href value to link to a specified mail address.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Send mail</button>

<script>
function myFunction() {//w  w w  . j a v a 2 s .c om
  location.href = "mailto:someone@example.com";
}
</script>

</body>
</html>



PreviousNext

Related