【发布时间】:2013-10-04 12:19:21
【问题描述】:
我有这个代码。
我为在我的网站上推广该页面而设置的。
<script ... >
document.write('<a href="mailto:?subject=my%20subject&body='+top.location.href+'">mail this link to a friend</a>');
</script>
但是在我的网址中,它在我的大多数广告系列中都有一个空间。这打破了我的促销电子邮件中的 url,因此直到第一个空格的 http:// 是超链接的。
如何将我的 url 中的空格替换为上面代码中的空格代码,这意味着整个链接将在电子邮件中超链接?
【问题讨论】:
-
您想替换
top.location.href中的空格吗?就这么简单:top.location.href.replace(/\s/g, '%20')
标签: javascript php email