在多个URL上有相同的Disqus线程

时间:2013-09-25 22:56:05

标签: javascript disqus

我有3个URL,所有这些都通向同一页面,例如:

www.example.com/index.php?q=8236894
www.example2.com/index.php?q=8236894
www.example3.com/index.php?q=8236894

因为查询字符串“q”都是相同的,所以我希望它们都加载相同的disqus线程。关于如何实现这一点的任何想法?

2 个答案:

答案 0 :(得分:3)

旧线程,但我遇到了同样的问题,所以我想我会分享我的解决方案!

提供的链接pedrum golriz是有帮助的。我们在此处实施了它:www.learnerds.com

在目标网页上,我们使用了以下代码:

<script>

var url = window.location.href;   \\ grabs the complete url with the query strings
var temp = new Array();  \\ creates an array that will store our values
temp = url.split('?');   \\ this function splits the url into 2 parts 
                         \\ temp[0] (everything before the question mark) & temp[1] (everything after the question mark)
disqus_url = temp[0];   \\sets the disqus_url to be the same regardless of query strings

</script>

您也可以使用window.location.href.split(&#39;?&#39;)[0]来减少代码行。

希望有所帮助!

答案 1 :(得分:0)

此处http://help.disqus.com/customer/portal/articles/472098-javascript-configuration-variables中的disqus文档应该有所帮助。

基本上,请确保将discus_ *变量设置为相同的值。此外,所有站点都需要添加到“受信任域”列表中(或者列表需要为空)。

相关问题