Javascript Form How to - Create an "email current page" button in HTML?








Question

We would like to know how to create an "email current page" button in HTML?.

Answer


<html>
<head>
    <script language="javascript">
        function emailCurrentPage(){<!--from w ww .  j  a v  a 2 s. c  o m-->
            window.location.href="mailto:?subject="+document.title+"&body="+escape(window.location.href);
        }
    </script>
</head>
<body>
        <a href="javascript:emailCurrentPage()">Mail this page!</a>
<body>
</html>

The code above is rendered as follows: