如何更改a + encodeURIComponent(location.href)以使用特定的URL而不是当前页面?
我试了这个没有运气:
onclick="window.open('https://www.facebook.com/sharer/sharer.php?u='http://www.domain.com/tell-a-friend/','facebook-share-dialog','width=626,height=436'); return false;"
这是Facebook API的原版。
<a href="#"
onclick="
window.open(
'https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href),
'facebook-share-dialog',
'width=626,height=436');
return false;">
Share on Facebook
</a>
答案 0 :(得分:1)
您的代码中有错误的引号:
onclick="window.open('https://www.facebook.com/sharer/sharer.php?u='http://www.domain.com/tell-a-friend/','facebook-share-dialog','width=626,height=436'); return false;"
^
将其更改为:
onclick="window.open('https://www.facebook.com/sharer/sharer.php?u=http://www.domain.com/tell-a-friend/','facebook-share-dialog','width=626,height=436'); return false;"