糟糕的JavaScript?你好酒吧独奏只在主页上工作 - 没有其他页面

bad javascript? hello bar solo only working on homepage - no other pages

本文关键字:工作 主页 其他 JavaScript 你好 酒吧      更新时间:2023-09-26

我正在经营一家大型商务商店,并在站点页脚中安装了hello bar solo自定义代码。我还尝试在各个位置(头模板文件、默认模板文件、特定于页面的模板文件(放置 hellobar 代码。 出于某种原因,hello-bar 仅适用于我的主页,但不适用于任何其他页面。

关于为什么的任何想法? 似乎如果我把它放在页脚中,它应该出现在每个页面上,但这不是我得到的。 如果您需要更多详细信息或代码示例来提供帮助,请告诉我。

谢谢

顺便说一句,BigCommerce 支持还认为,如果我在页脚中有此代码,hellobar 应该出现在每个页面上,但它不起作用。 我的猜测是它是JavaScript,但我不知道如何解决这个问题。

这是我使用的代码:

   <div id="mailchimp_form" style="display:none;">
<form action="http://xxxxx.us5.list-manage.com/subscribe/post" method="POST">
<input type="hidden" name="u" value="xxxxxxxx">
<input type="hidden" name="id" value="xxxxx">
Get an instant coupon code by signing up to our newsletter.  Email: <input type="email" autocapitalize="off" autocorrect="off" name="MERGE0" id="MERGE0" size="25" value="" />
<input class="button" type="submit" value="Subscribe" />
</form>
</div>
<!-- Hello Bar configuration start -->
<script type="text/javascript">
var mailChimpForm = document.getElementById('mailchimp_form').innerHTML;
new HelloBar( mailChimpForm, {
    showWait: 1000,
    positioning: 'sticky',
    fonts: 'Arial, Helvetica, sans-serif',
    forgetful: true
}, 1.0 );
</script>

以下是我放在标题中的引用:

<link type="text/css" rel="stylesheet" href="content/hellobar.css" />
<script type="text/javascript" src="content/hellobar.js"></script> 

不知道什么是bigcommerce,但从您提供的内容来看,我猜测有两个原因之一。

  1. 除了您的主页外,没有"mailchimp_form"div。
  2. 出于某种奇怪的原因,Javascript确实在"mailchimp_form"div加载到所有其他页面上之前被执行。