我正在开发一个网站,该网站的页面不会加载,网址只会更改并且页面会显示。我向页面添加了 JavaScript 代码,但该代码仅在刷新页面时运行,而不是在单击链接访问页面时运行。有人可以帮我吗?
这是代码:
<script>
var idcomments_acct = '83e4fbf73e5268d6ddbbabd9e697add5';
var idcomments_post_id;
var idcomments_post_url;
</script>
<span id="IDCommentsPostTitle" style="display:none"></span>
<script type='text/javascript' src='https://www.intensedebate.com/js/genericCommentWrapperV2.js'>
</script>
最佳答案
在 Squarespace 中,当您的自定义 Javascript 仅在页面刷新后才起作用时,它很可能与 Squarespace's AJAX loading 有关。 :
Occasionally, Ajax may conflict with embedded custom code or anchor links. Ajax can also interfere with site analytics, logging hits on the first page only.
您也许能够disable AJAX for your template 。或者,请参阅此处概述的其他方法:https://stackoverflow.com/a/42604055/5338581
关于由于 url 更改且页面未加载,JavaScript 未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44815644/