krish kr
krish kr

Reputation: 887

How to append Java Script code in mailto body text

And my code goes as below which breaks at the JS code snippet when the mail box opens.

<a href="mailto:?subject=This is My Subject&body=Hithis is my text and my page url is"+window.location.href+\" click link to see Greater experienceto" target="_top" class="">

Email

Where as i wanted it to display the url dynamically where the link is available in the page.Expected email

Upvotes: 1

Views: 771

Answers (2)

user2805507
user2805507

Reputation:


Your browser might not might support. have you tried updating your browser or reinstalling? Cross browser testing will always have problems when you are implementing inbuild functions. For myself . i will always build my own form to avoid these kind of circumstances. its long winded concept but always safest and will save more time in the future. for an example ... Creating your own mail form ..`dds

<form action="mailto:[email protected]" method="post" enctype="text/plain">
Name:<br>
<input type="text" name="name"><br>
E-mail:<br>
<input type="text" name="mail"><br>
Mail:<br>
<input type="text" name="email" style="width:600px; height: 100px"><br><br>
<input type="submit" value="Send">
<input type="reset" value="Reset">
</form>

`

Try this. I hope it will help.. If you want to be exactly the same as the one you posted above. you just need to do some styling. what i would recommend is to add a div and wrap the form in it. so for example.

<div id="main-container">
  <form>..
  ..
  ..
  ..
  </form>
</div>

Cheers. :)

Upvotes: 0

Robby
Robby

Reputation: 827

Try it this way:

<a href="#" onclick="javascript:window.location='mailto:?subject=Interesting information&body=I thought you might find this information interesting: ' + window.location + ' click link to see Greater experienceto'">Click</a>

Upvotes: 1

Related Questions