我无法通过测试,因为canoo不支持外部js-file中的全局变量。
index.html:
<html>
<head>
<script src="index.js"></script>
</head>
<body>
<button onclick="alert(a+1);">asldkf</button>
</body>
</html>index.js
var a=1;CanooWebtest抛出:
JavaScript error loading page
http://localhost:8080/index.html:
ReferenceError: "a" is not defined. (JavaScriptStringJob#1)有什么建议吗?
发布于 2013-01-30 21:38:53
您总是可以欺骗它,并将其添加到一个全局对象-窗口,文档...这不是一个好的解决方案,但应该是可行的。
<script>
window.a = 1;
</script>https://stackoverflow.com/questions/14605191
复制相似问题