Results 1 to 5 of 5
  1. #1
    Web Ho - Design B!tch ~Michelle's Avatar
    Join Date
    January 18th, 2005
    Location
    Michigan
    Posts
    2,040
    Javascript "mail to a friend" help please
    I have tried numerous mail to a friend javascripts on a certain website and none of them work as they are supposed to.

    They fill in the subject, but never fill in the body with the specified text.

    I know it has to be something on the webpage itself, but I can't figure out what. I went through and did process of elimation as far as other scripts on the page because there was a rotating text script, etc, but even with those removed these mail to scripts are not working.

    Currently I am using the following in the head of the page:

    Code:
     <script language="javascript">
      function mailpage()
      {
      mail_str = "mailto:?subject=Check out " + document.title;
      mail_str += "&body=I thought you might be interested in the " + document.title;
      mail_str += ". You can view it at, " + location.href;
      location.href = mail_str;
      }
      </script>
    and this around the image that I want to use as the clickable link
    Code:
    <A HREF = "javascript:mailpage()"><img SRC="tellafriend.jpg" ALT="Click Here To Tell A Friend About This Site" height=20 width=165 border=0></A>
    If anyone thinks they can help me troubleshoot this problem just let me know and I will PM you the URL of the page in question.

    Thanks!
    ~Michelle
    "All I ask is a chance to prove that money can't make me happy."
    "Work to become, not to acquire." -- Confucius

  2. #2
    ABW Ambassador sjangro's Avatar
    Join Date
    January 18th, 2005
    Location
    Boston
    Posts
    1,529
    Michelle, I just tried a simple test with only this code in it and it works for me.

    Does this work for you on a page containing only this JS?
    I'd take a quick look if you want to provide the URL.

  3. #3
    Web Ho - Design B!tch ~Michelle's Avatar
    Join Date
    January 18th, 2005
    Location
    Michigan
    Posts
    2,040
    Thanks! I have sent you a PM.
    ~Michelle
    "All I ask is a chance to prove that money can't make me happy."
    "Work to become, not to acquire." -- Confucius

  4. #4
    ABW Ambassador sjangro's Avatar
    Join Date
    January 18th, 2005
    Location
    Boston
    Posts
    1,529
    The problem is that an ampersand in the title tag is breaking the url in the mailpage function. any time you put data in a URL, unless you're sure it won't have special characters in it (spaces, ?, &), you need to encode it.

    Try this for your mailpage() function:

    Code:
    function mailpage()
    {
      mail_str = "mailto:?subject=" + escape ("Check out " + document.title);
      mail_str += "&body=" + escape("I thought you might like " + document.title);
      mail_str += escape (". You should check this out at, " + location.href);
      location.href = mail_str;
    }

  5. #5
    Web Ho - Design B!tch ~Michelle's Avatar
    Join Date
    January 18th, 2005
    Location
    Michigan
    Posts
    2,040
    Woohoo! It works now! I never thought to look at the title.

    You da' man!

    Thank you!!

    ~Michelle
    ~Michelle
    "All I ask is a chance to prove that money can't make me happy."
    "Work to become, not to acquire." -- Confucius

  6. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. How should I handle my "Pyramid Friend?"
    By Rhia7 in forum Virtual Family and Off-Topic
    Replies: 34
    Last Post: March 5th, 2010, 10:18 PM
  2. "tell-a-friend" scripts: What to look for?
    By pokerturkey in forum Midnight Cafe'
    Replies: 11
    Last Post: November 17th, 2005, 03:30 AM
  3. Replies: 2
    Last Post: July 29th, 2005, 01:51 PM
  4. Putting a "'" in JavaScript?
    By madmanbc in forum Programming / Datafeeds / Tools
    Replies: 2
    Last Post: January 5th, 2002, 08:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •