<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>
上述脚本的目标是获取当前url并向其附加ref查询字符串。然后我们更改链接的href以添加自定义mailto。
以上似乎在桌面上运行得非常好。但是在移动设备(Chrome iphone)上,当我点击电子邮件共享链接时,?ref = blogshare不会被附加到链接。
任何想法为什么?
答案 0 :(得分:1)
您需要编码查询字符串值。
var currentPostUrl = encodeURIComponent(window.location.href + "?ref=blogshare");