我正在测试Google酒店定价工具,当我在head标签之间直接粘贴脚本时它工作正常,将值附加到DOM(附加截图)。 但是如果以编程方式创建脚本,则无法创建这些值。代码如下所示:
工作示例:
<head>
<script type="text/javascript">
var google_conversion_id = 1;
var google_conversion_domain = "www.googletraveladservices.com/travel/clk";
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"></script>
</head>
非工作示例:
<script type="text/javascript">
var google_conversion_id = 1;
var google_conversion_domain = "www.googletraveladservices.com/travel/clk";
var s = document.createElement("script");
s.type = "text/javascript";
s.src = "//www.googleadservices.com/pagead/conversion.js";
document.head.appendChild(s);
</script>