[英]I can't figure out why my javascript isn't working… I'm dynamically passing values to a tag
I have the below code: 我有以下代码:
<html>
<body>
<script>
var Orderid = 12345;
var Quantity = 2;
var Revenue = 10.50;
var Red = NorthAmerica;
var Blue = Canada;
var Green = French;
var Yellow = 20.00;
document.write('<s' + 'cript language="JavaScript" src="http://jact.atdmt.com/jaction/JavaScriptTest/v3/ato.' + Orderid + '/[atm1.' + Quantity + '/atm2.' + Revenue + '/atc1.' + Red + '/atc2.' + Blue + '/atc3.' + Green + '/atc4.' + Yellow + ']"></s'+'cript>')
document.write('<nos' + 'cript><iframe src="http://iact.atdmt.com/iaction/JavaScriptTest/v3/ato.' + Orderid + '/[atm1.' + Quantity + '/atm2.' + Revenue + '/atc1.' + Red + '/atc2.' + Blue + '/atc3.' + Green + '/atc4.' + Yellow + ']" width="1" height="1" frameborder="0" scrolling="No" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0"></iframe></nosc' + 'ript>')
</script>
</body>
</html>
The purpose of this is to pass variables to a URL (action tag) for tracking on a webpage. 这样做的目的是将变量传递到URL(操作标记)以在网页上进行跟踪。
I've always done it like this in the past, but for some reason my action tag (jact.atdmt.com or iact.atdmt.com) is not being called this time. 过去,我一直这样做,但是由于某种原因,这次没有调用我的动作标签(jact.atdmt.com或iact.atdmt.com)。 Am I doing something wrong that I'm not catching?
我做错什么了吗? Ideally I would like to keep using the same format as above... I just can't think of why it would not be working.
理想情况下,我想继续使用与上述相同的格式...我只是想不出为什么它不起作用。
Thanks, 谢谢,
You need quotes around those strings or else they will be treated as undefined variables... 您需要在这些字符串周围加上引号,否则它们将被视为未定义的变量...
var Red = 'NorthAmerica';
var Blue = 'Canada';
var Green = 'French';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.