<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不会被附加到该链接上。
你知道为什么吗?
发布于 2015-09-18 09:01:32
您需要对查询字符串值进行编码。
var currentPostUrl = encodeURIComponent(window.location.href + "?ref=blogshare");https://stackoverflow.com/questions/32642126
复制相似问题