javascript 实现基本 Sharethis 代码时指定了无效或非法字符串
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11606948/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
An invalid or illegal string was specified when implementing basic Sharethis code
提问by K Scandrett
I'm trying to implement ShareThis buttons on a page, but cannot get the basic options to work in FF or Chrome, on win 7 or Vista.
我正在尝试在页面上实现 ShareThis 按钮,但无法获得在 FF 或 Chrome、win 7 或 Vista 中工作的基本选项。
Chrome has no plugins. Have disabled FF plugins.
Chrome 没有插件。已禁用 FF 插件。
Not sure if the problem is some dumb mistake I'm making, or if it is with ShareIt JS code.
不确定问题是否是我犯的一些愚蠢的错误,或者是否与 ShareIt JS 代码有关。
Steps:
1. Signed up
2. Went to http://sharethis.com/publishers/get-sharing-tools
3. Completed the 3 steps (changes: Added Pinterest and removed ShareThis button
4. Created a html file and pasted the code
步骤:
1. 注册
2. 前往http://sharethis.com/publishers/get-sharing-tools
3. 完成 3 个步骤(更改:添加 Pinterest 并删除 ShareThis 按钮
4. 创建一个 html 文件并粘贴代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="en-us" />
<script type="text/javascript">var switchTo5x=true;</script>
<script type="text/javascript" src="http://w.sharethis.com/button/buttons...; /script>
<script type="text/javascript">stLight.options({publisher: 'beea8274-700e-4d53-aeff-393478c86a40'}); </script>
</head>
<body>
<span class='st_facebook_large' displayText='Facebook'></span>
<span class='st_twitter_large' displayText='Tweet'></span>
<span class='st_linkedin_large' displayText='LinkedIn'></span>
<span class='st_pinterest_large' displayText='Pinterest'></span>
<span class='st_email_large' displayText='Email'></span>
</body>
</html>
On Page load in Firefox I get SyntaxError: An invalid or illegal string was specified. Email button popup just says 'loading....', and 'Pick one or more destinations:' has no options.
在 Firefox 中加载页面时,我收到 SyntaxError:指定了无效或非法字符串。电子邮件按钮弹出窗口仅显示“正在加载....”,而“选择一个或多个目的地:”没有选项。
Pulled much hair out over this.
为此拉了很多头发。
Thanks
谢谢
采纳答案by K.C.Ashish Kumar
Have you deployed your html file on a server before testing it on a browser. If you are testing the html file directly by placing on your Desktop or some other folder, then it will not work. You need to deploy the html file to a server eg: Tomcat or whichever you are comfortable with.
在浏览器上测试之前,您是否在服务器上部署了 html 文件。如果您通过放置在桌面或其他文件夹上来直接测试 html 文件,那么它将不起作用。您需要将 html 文件部署到服务器,例如:Tomcat 或您喜欢的任何服务器。