0
<script>// <![CDATA[
$(function(){
  var currentPostUrl = window.location.href + "?ref=blogshare"
  var currentPostTitle = $('.post-title').text().trim();

  $('#myModal').appendTo("body") 

  var facebookShareUrl = "https://www.facebook.com/sharer/sharer.php?u=" + currentPostUrl
  var emailShareUrl = "mailto:?to=&body=Hey, I thought you might like this post. It's called " + currentPostTitle + ". You can read it here:  " + currentPostUrl + "&subject=Thought you might like this post..."


  $('.email-share').attr('href', emailShareUrl);

// ]]></script>

The goal of the above script is to get the current url and append a ref query string to it. Then we change the href of a link to add a custom mailto.

The above seems to work perfectly fine on desktop. But on mobile (chrome iphone), when I click the email-share link, the ?ref=blogshare is not being appended to the link.

Any ideas why?

2
  • You need use encodeURIComponent... Commented Sep 18, 2015 at 0:45
  • That was it, thanks! Commented Sep 18, 2015 at 0:56

1 Answer 1

1

You need to encode querystring values.

encodeURIComponent()

var currentPostUrl = encodeURIComponent(window.location.href + "?ref=blogshare");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.