Forum Moderators: open

Message Too Old, No Replies

How to auto-insert the page name into a subject line with mailto:

         

youfoundjake

11:11 pm on Jul 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I want my users to be able to click on an email link that automatically starts an email address to me with a certian subject line as well as what page the link was generated from, so i know what they are referring to. is it possible?
using <a href="mailto:questions@example.com?subject=someinfo"> right now.

Is there a variable that can be used, or do I have to use php to insert it?

phranque

11:19 pm on Jul 20, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



you could use javascript to access the page title from the DOM and reassign the href value for the anchor tag.

rocknbil

7:12 pm on Jul 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If your pages are output by php, this would be the choice as it would not be Javascript dependent.

Otherwise a simple document.write would work:


<script type="text/javascript">
var link = '<a href="mailto:your_email@?subject=Question\%20From\%20' +
document.location + '">Questions?<\/a>';
document.write(link);
</script>

youfoundjake

9:14 pm on Jul 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



RocknBill, perfect thanks alot
<script type="text/javascript"> var link = '<a href="mailto:test@example.com?subject=Update concerning\%20' + document.title + '">update<\/a>'; document.write(link); </script>

I changed the document variable to title to get the title of the page and it works beautifully, mucho gracias.