No announcement yet.

how to emply URLEncode method with the window.location

  • Filter
  • Time
  • Show
Clear All
new posts

  • how to emply URLEncode method with the window.location

    I know I'm mixing languages, here, but I'm a novice who is piecing together code snippets I've found... and I'm almost there!

    I'm inserting code into a SharePoint Page layout so that a user can click on a link and it will open their default e-mail program in order to send the URL of the current page to someone of their choice. This html works for that purpose:
    <a href="mailto:?subject=Tech-i-pedia article for you&body=[sub]" onclick="this.href = this.href.replace('[sub]',window.location)">Send to a friend</a>

    ...except that it doesn't handle the spaces in the href as ASCII. Meanwhile, I've found the code that does that here:

    How do I put these two together (or an alternative that doesn't involve forms, please)?

  • #2
    to clarify... for example if I have a page with the URL ...test.aspx, the tag works great. However, if the URL is test%20page.aspx, it's passing that along as if it was
    "test page.aspx", at which point Outlook renders that link incorrectly by dropping the "page.aspx".

    If it's an Outlook issue, i'm out of luck, of course. But I'm hoping this is fixable in the web page itself.