Link to home
Create AccountLog in
Avatar of rtod2
rtod2Flag for United States of America

asked on

Make link clickable without entry

This page http://www.frugalmule.com/current-project/ contains the code that follows.  Currently, you have to at least put the cursor into the field shown in order to make get the "Click to Send Email" link actually work.  How do I avoid that?
<input type="text" id="send_email" onBlur="document.getElementById('email_link').href = 'mailto:' + this.value + '?subject=Title of Post&body=' + document.URL; ">
<a href="javascript:void(0)" id="email_link">Click to Send Email</a>

Open in new window

Avatar of sammySeltzer
sammySeltzer
Flag of United States of America image

Well, if you don't want to have to enter something before invoking email via the click, then forget the javascript and use something simpler:

    <tr>
      <td width="407"><font face="Verdana, Arial, Helvetica" color="#FFCC00"><font face="Arial"><a href="mailto:youremail?subject=whateverYouwant" target="_self">Click
        to send Email</a></font></h3>
        </td>
    </tr>

Unless of course there is a reason to use javascript.
Avatar of rtod2

ASKER

Sammy, Thank you!

That's a better approach I think but only if it would behave the same way I am after with the javascript.

Can you make your solution perform the following tasks:
1. place a link to the page into the body of the email
2. title the page by the title of the post.
This may help too:

<html>
<head>
<script>
function updateEmailLink(){
  var thisPage = window.location.pathname;
  document.getElementById('email_link').href = 'mailto:' + this.value + '?subject=Check Out This Link&body=' + thisPage;
}
</script>
</head>
<body>
<label>Email Address: </label>
<input type="text" id="send_email" onBlur="javascript:updateEmailLink();">

<a href="javascript:void(0)" id="email_link">Click to Send Email</a>
<script>
updateEmailLink();
</script>
</body>
</html>

Open in new window


taken from
https://www.experts-exchange.com/questions/27431771/Modify-mailto-code.html


Now, that I took another look at that link, that was you too!

Didn't that solution work for you?
Avatar of rtod2

ASKER

No, that solution does not put a link into the body of the email.
Tell me, what is the body of email?
Avatar of rtod2

ASKER

Purpose:

Click link which will bring up the new mail message box your default email program.
The Title and Body of the email get automatically populated with the Title of the page, and the link back to the page.

To answer your question more directly, the body of the email should contain a link back to the page that contains the original link.
ASKER CERTIFIED SOLUTION
Avatar of sammySeltzer
sammySeltzer
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of rtod2

ASKER

Sammy,
Thanks for trying to help.  Your last solution produces this http://screencast.com/t/RM2aLospK .
What I am trying to produce would look like this http://screencast.com/t/MDAe8McT.

Notice that there is room to start entering text about the page you are forwarding a link to and the title takes on the title of the page you are discussion.  The email address is blank to allow for whatever the person wants to put in from their own address book.
Avatar of rtod2

ASKER

Not quite, Sammy.  I'll try to further break this down into its components