0

我刚刚开始创建一个新网站,目前还没有在互联网上。我的第一个网站,所以一切对我来说都是新的。我正在尝试实现 Facebook like 按钮。我已输入代码,但没有显示任何内容。我正在使用 TextWrangler 创建网站并使用 MacBook Air。不确定这些信息是否会有所帮助。也许由于元属性而无法正常工作?我不太明白我需要在那里输入什么信息。

这是我的代码:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>[]</title>
<meta property="og:title" content="The []" />
<meta property="og:type" content="website" />
<meta property="og:url" content="file:///Users/[]/Documents/Sites/IBS.html" />
<meta property="og:image" content="http://[].jpeg" />
<meta property="og:site_name" content="The []" />
<meta property="fb:admins" content="218100060" />
</head>
<body>
<p>hello</p>
<iframe   src="//www.facebook.com/plugins/like.phphref=file%3A%2F%2F%2FUsers%2Fshikhaverma%2FDocuments%2FSites%2FIBS.html&amp;
send=false&amp;layout=standard&amp;width=450&amp;show_faces=true&amp;font=arial&amp;
colorscheme=light&amp;action=like&amp;height=80" scrolling="no" frameborder="0" 
style="border:none; overflow:hidden; width:450px; height:40px;" allowTransparency="true">
</iframe>
</body>
</html>

如果您能提供帮助,我将不胜感激。谢谢你。

4

1 回答 1

1

The problem is that the code you provided is double escaped. Which means that they are "&amp"s everywhere in the iFrame URL (src) code you provided:

//www.facebook.com/plugins/like.phphref=file%3A%2F%2F%2FUsers%2Fshikhaverma%2FDocuments%2FSites%2FIBS.html&amp;
send=false&amp;layout=standard&amp;width=450&amp;show_faces=true&amp;font=arial&amp;
colorscheme=light&amp;action=like&amp;height=80

Try pasting the url in your web browser, and it won't work, because it's so mal-formed.

Besides, Facebook like button can't use a local url to like, (in this case you used file:///Users/shikhaverma/Documents/Sites/IBS.html. ). It has to be using an online, functioning URL. So for now, just enter any random URL of an online website untill you get your site hosted online.

I un-escaped the url, and it's still mal-formed. It should be "like.php?href=file" instead of "like.phphref=file". Why don't you just go back to Facebook and re-generate the code.

Also, is there a problem with your code editor? Why is everything getting double-escaped?

Edit: By the way, you can always utilize the unescape() JavaScript command to unescape text. More here on Mozilla dev.

于 2012-12-27T00:06:05.077 回答