【发布时间】:2018-02-08 01:28:49
【问题描述】:
我正在尝试将 JavaScript 函数导入我的 HTML 文档。它可以在 Chrome 上运行,但是在 IE11 中它返回的“aFunction”是未定义的。
我已阅读大量帮助主题,但仍无法找到解决方案。
我的代码如下。
索引.html
<head>...
<script type="text/javascript" src="test.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var myFunction = aFunction();
//print to console to see if variable has anything in it
console.log(myFunction);
});
</script>
...</head>
test.js
function aFunction(){ //some code... }
任何想法将不胜感激。
【问题讨论】:
-
所以我在developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… 找到了答案,因此不再需要回复这个帖子。我不认为模板文字在第一种情况下很重要,但现在我知道否则感谢您尝试帮助我解决这个问题。
-
如果您要放弃这个问题,请删除它。
标签: javascript jquery html internet-explorer undefined