We help IT Professionals succeed at work.

Make link clickable without entry

rtod2
rtod2 asked
on
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

Comment
Watch Question

Top Expert 2011

Commented:
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.

Author

Commented:
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.
Top Expert 2011

Commented:
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
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_27431771.html


Top Expert 2011

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

Didn't that solution work for you?

Author

Commented:
No, that solution does not put a link into the body of the email.
Top Expert 2011

Commented:
Tell me, what is the body of email?

Author

Commented:
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.
Top Expert 2011
Commented:
Did you mean this?

I am still trying to get it.

    <tr>
      <td width="407"><font face="Verdana, Arial, Helvetica" color="#FFCC00"><font face="Arial"><a href="mailto:youremail?subject=Title of Post&body= + document.URL; " target="_self">Click
        to send Email</a></font></h3>
        </td>
    </tr>

Author

Commented:
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.

Author

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

Explore More ContentExplore courses, solutions, and other research materials related to this topic.