开发者

We need to have url (address bar information) email from a web page [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its cur开发者_JS百科rent form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜