我有 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线程。关于如何实现这一目标的任何想法?
旧线程,但我遇到了同样的问题,所以我想我会分享我的解决方案!
佩德鲁姆·戈里兹提供的链接很有帮助。我们在这里实现了它: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('?'([0] 用于更少的代码行数。
希望对您有所帮助!
在这里找到的disqus文档 http://help.disqus.com/customer/portal/articles/472098-javascript-configuration-variables 应该会有所帮助。
基本上,请确保将 discus_* 变量设置为相同的值。此外,所有站点都需要添加到"受信任的域"列表中(或者,列表需要为空(。