mootools 资产未加载
我正在尝试在“成功”页面与表单页面相同的页面(重新发布到同一页面并设置消息)的情况下动态触发 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 readsyo
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我只是在 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/