开发者

mootools asset not loading

开发者 https://www.devze.com 2023-03-08 09:33 出处:网络
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 m

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. He开发者_如何学Gore'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


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/

0

精彩评论

暂无评论...
验证码 换一张
取 消