Javascript 通过符号传递到twitter意图
使用Twitter功能创建随机报价生成器 单击按钮从API生成报价,此时会显示报价,用户可以选择是否发送该报价 我的问题是,如果不将字符转换为&sdfkj;,我不知道如何将撇号和破折号等符号传递到URL;(或者随便什么) 代码: HTML: 随机生成的报价: 已将报价传递到Twitter intent(未编码): 正如您所看到的,生成的报价被截断了。所以我在网上搜索了一下,发现encodeURIComponent()似乎是个不错的选择 但现在,这句话看起来很奇怪 有什么功能或方法可以帮助我解决这个问题吗 谢谢, 詹姆斯Javascript 通过符号传递到twitter意图,javascript,html,ajax,api,twitter,Javascript,Html,Ajax,Api,Twitter,使用Twitter功能创建随机报价生成器 单击按钮从API生成报价,此时会显示报价,用户可以选择是否发送该报价 我的问题是,如果不将字符转换为&sdfkj;,我不知道如何将撇号和破折号等符号传递到URL;(或者随便什么) 代码: HTML: 随机生成的报价: 已将报价传递到Twitter intent(未编码): 正如您所看到的,生成的报价被截断了。所以我在网上搜索了一下,发现encodeURIComponent()似乎是个不错的选择 但现在,这句话看起来很奇怪 有什么功能或方法可以帮助我
<!DOCTYPE html>
<html>
<head>
<title>Random Quote Generator</title>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="container">
<h1>Random Quotes Rewritten</h1>
<p>Would you like a random sentence to send to someone or incorporate in your project? Press the button below!</p>
<div class="quotearea">
</div>
<button id="newquote">New quote</button>
<button class="tweetquote"><i class="fa fa-twitter" aria-hidden="true"></i>
Tweet Quote</button>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="script.js"></script>
</body>
var quoteObj;
var quoteContent;
var quoteTitle;
$("#newquote").click(function(){
$.getJSON("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=30&jsonp=mycallback", function(a) {
$(".quotearea").empty();
$(".quotearea").addClass("border");
quote = a[Math.floor(Math.random()*a.length)];
quoteContent = quote.content;
quoteTitle = quote.title;
$(".quotearea").append(quoteContent + " " + quoteTitle);
$('.tweetquote:hidden').show();
});
});
$('.tweetquote').click(function() {
window.open('https://twitter.com/intent/tweet?text=' + quoteContent + quoteTitle);
});