本文介绍了如何在我网站的每个网页上嵌入一个类似Facebook的按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我应该代替以下内容:http%3A%2F%2Fexample.com%2Fpage%2Fto%2Flike,以便它返回网页的永久链接.我想在网站的每个网页中插入相同的代码.
What should I put instead of: http%3A%2F%2Fexample.com%2Fpage%2Fto%2Flike in this href field so that it returns the permalink of the webpage. I want to insert the same code in every webpage of the website.
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fexample.com%2Fpage%2Fto%2Flike&layout=standard&show_faces=true&a
mp; width=450&action=like&colorscheme=light&height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>
推荐答案
这取决于您使用的服务器端语言.在PHP中,您可以执行以下操作,在其中引用 $ _ SERVER ['REQUEST_URI']
:
It depends on what server-side language you're using. In PHP you could do something like this, where I reference $_SERVER['REQUEST_URI']
:
<?php $encodedUrl = htmlentities(urlencode($_SERVER['REQUEST_URI'])); ?>
<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo $encodedUrl; ?>&layout=standard&show_faces=true&width=450&action=like&colorscheme=light&height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>
如果您不使用服务器端语言,则可以使用JavaScript进行.这未经测试,但是:
If you're not using a server-side language, you could do it in JavaScript. This is untested, but:
<script type="text/javascript">
var encodedUrl = escape(encodeURIComponent(window.location));
document.write('<iframe src="http://www.facebook.com/plugins/like.php?href=' + encodedUrl + '&layout=standard&show_faces=true&width=450&action=like&colorscheme=light&height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>');
</script>
这篇关于如何在我网站的每个网页上嵌入一个类似Facebook的按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!