我在我的网站(http://www.xeasycorex.net)上为每个帖子中的Tumblr按钮使用以下脚本。该strPostTitle.replace
线逃逸任何双引号,但我需要为单引号做同样的,因为它的终止字符串当存在于文章标题,而不是显示的按钮,我只是不知道如何做到这一点如何在Javascript中转义单引号?
谢谢!
<script>
var strPostUrl = "<data:post.url/>";
var strPostTitle = '<data:post.title/>';
var strNewUrl = strPostUrl.replace("http://","");
var strNewTitle = strPostTitle.replace(/"/g, '"');
document.write("<a href='http://www.tumblr.com/share/link?url="+strNewUrl+"&name="+strNewTitle+"'><img src='https://lh4.googleusercontent.com/-Vw74mICSigg/USjO29GAujI/AAAAAAAARHE/dY0nzXtwTVU/s81/tumblr-share.png'/></a>");
</script>
使用\”逃单引号 – kinakuta 2013-03-12 02:51:39
如何为'<数据: post.url />代入? – icktoofay 2013-03-12 02:58:42