我有這段代碼。用代碼替換url中的空間
我所建立促進我的網站上的頁面。
<script ... >
document.write('<a href="mailto:?subject=my%20subject&body='+top.location.href+'">mail this link to a friend</a>');
</script>
但是,在我的網址中,我的大部分廣告系列都有空格。這打破了我的促銷電子郵件中的網址,因此到第一個空間的http://
超鏈接。
如何更換在上述意義上的代碼空間代碼,整個鏈接將在電子郵件超鏈接在我的網址的空間?
你要替換'top.location.href'的空間?簡單如此:'top.location.href.replace(/ \ s/g,'%20')' –