It needs to work like this: Someone lands on a webpage, then they “click” a button found on that page, the current page's URL needs to be emailed and the user sent to a new web page.
Can this happen? If so, does anyone know the code?
Many thanks Michael
You can't really do exactly what you're asking in pure HTML. The sending email part you'd have to do on your server so you'll either need some sort of server-side code (eg: php, a cgi, a servlet, etc.) or you'll need to find a pre-built solution.
Have your button in a form. Also have a hidden field for the page's URL. Either have an onsubmit on the form that sets the hidden field to document.location
, or have the server set the field's value when delivering the page (presumably you know the page's URL when you're rendering it). The form then submits to the emailing action on your server which will get the URL as a parameter.
If that isn't possible, the closest you can get to sending mail client-side is a mailto:
link. You can add parameters to a mailto:
link to specify the body and subject, but note that the user will be able to edit the email or cancel it entirely.
Check window.location
. http://www.w3schools.com/jsref/obj_window.asp
Send your e-mail server-side.
精彩评论