mootools 资产未加载

发布于 2024-11-09 21:39:10 字数 1375 浏览 2 评论 0原文

我正在尝试在“成功”页面与表单页面相同的页面(重新发布到同一页面并设置消息)的情况下动态触发 Google adwords 转换。因此,我设置了消息并使用 javascript 检查它,然后应该加载 adwords 转换 js。这是代码:

<script type="text/javascript">
        //<![CDATA[
        window.addEvent('domready', function() {
            var convmessage = null;
            convmessage = $('message');

            if(!!convmessage) {
                console.log("yo");
                if ($('message').getChildren()[1].innerText){
                    console.log("yoyo");        
                    var google_conversion_id        = 1234;
                    var google_conversion_language  = "en-US";
                    var google_conversion_format    = "1";
                    var google_conversion_color     = "ffffff";
                    var google_conversion_label     = "Label";

                    var myScript = Asset.javascript('http://www.googleadservices.com/pagead/conversion.js', {
                        id: 'myScript',
                        onLoad: function(){
                            console.log("loaded");
                        }
                    });

                }
            }

        });
        //]]>
    </script>

当我提交表单时,我的控制台日志显示 悠悠球 但从不显示 loaded 消息。因此,看起来脚本应该被加载,但从未加载,即使脚本(显然)正确执行。

使用 mootools asset 函数是否缺少某些内容,或者脚本未加载的其他原因?

谢谢

I'm trying to dynamically trigger a Google adwords conversion in a situation where the "success" page is the same page as the form page (reposts to the same page and sets a message). So I set the message and check for it with javascript, which then should load the adwords conversion js. Here's the code:

<script type="text/javascript">
        //<![CDATA[
        window.addEvent('domready', function() {
            var convmessage = null;
            convmessage = $('message');

            if(!!convmessage) {
                console.log("yo");
                if ($('message').getChildren()[1].innerText){
                    console.log("yoyo");        
                    var google_conversion_id        = 1234;
                    var google_conversion_language  = "en-US";
                    var google_conversion_format    = "1";
                    var google_conversion_color     = "ffffff";
                    var google_conversion_label     = "Label";

                    var myScript = Asset.javascript('http://www.googleadservices.com/pagead/conversion.js', {
                        id: 'myScript',
                        onLoad: function(){
                            console.log("loaded");
                        }
                    });

                }
            }

        });
        //]]>
    </script>

When I submit the form, my console log reads
yo
yoyo
but never displays the loaded message. So it appears that the script should get loaded but never does, even though the script (apparently) executes properly.

Is there something I'm missing about using the mootools asset function, or another reason that the script doesn't get loaded?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

﹏半生如梦愿梦如真 2024-11-16 21:39:10

我只是在 JS Fiddle 上检查这个功能,它对我来说工作得很好。只是不符合你的剧本。

看起来 Google 正在强制下载该脚本,这似乎破坏了 mootools 脚本。我会尝试在您自己的服务器上托管该脚本或使用另一服务器。

你可以在这里看到我做了什么:
http://jsfiddle.net/9h8Zx/1/

I was just checking this function on JS Fiddle, and It worked fine for me. Just not with your script.

It looks like Google is force downloading the script, which it looks like breaks the mootools script. I would try hosting that script on your own server or use another one.

You can see what I did here:
http://jsfiddle.net/9h8Zx/1/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文