【发布时间】:2016-01-14 08:25:38
【问题描述】:
我是 JavaScript 新手。当我尝试以下代码时,我的 js 文件没有被链接,并且 html 页面中的 JavaScript 代码没有被执行: html 和 JavaScript 文件都在同一路径。
我的html:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;>
<title>JS Code</title>
</head>
<body>
HTML
<script type="text/javascript" src="script.js">
debugger;
document.write("HI i am from HTML with js code")
nowCall1();
function nowCall1(){
document.write("-Js.")
//peakOil(changeCivilisationCallback);
}
</script>
</body>
</html>
script.js:
function peakOil(callback) {
document.write("HI i am from Js");
callback(); // the parentheses mean the function is executed!
}
function changeCivilisationCallback(){
document.write("HI i am from changeCivilisationCallback");
}
function nowCall(){
document.write("Js.")
//peakOil(changeCivilisationCallback);
}
但是当我尝试删除 scr 属性时,将所有代码放入 html 脚本中。为什么当我尝试将代码放入 js 文件时,它没有被执行。我在 google chrome 浏览器中调试时遇到问题。
请帮助我理解javas cript,在此先感谢。
【问题讨论】:
-
代码充满了错误。你想做什么?
标签: javascript html javascript-debugger