A function cannot be called unless it was defined in the same file or one loaded before the attempt to call it.
(除非在同一文件中定义了该函数,或者在尝试调用该函数之前已加载了一个函数,否则无法调用该函数。)
A function cannot be called unless it is in the same or greater scope then the one trying to call it.
(除非函数的范围与尝试调用该函数的范围相同或更大,否则不能调用该函数。)
You declare function fn1
in first.js, and then in second you can just have fn1();
(在first.js中声明函数fn1
,然后在第二秒中就可以拥有fn1();
)
1.js:
(1.js:)
function fn1 () {
alert();
}
2.js:
(2.js:)
fn1();
index.html :
(index.html:)
<script type="text/javascript" src="1.js"></script>
<script type="text/javascript" src="2.js"></script>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…