Javascript 将值从一个文件发送到另一个文件
Javascript send value from one file to another file
对不起我的英语。我想知道是否可以将一个文件发送到另一个文件变量?
例如
oneFile.js
var a = true;
twoFile.js
if(a == true) {
alert("hellow");
}
好吧,如果 oneFile.js
在 twoFile.js
之前加载,它将起作用。尽管这种确切的情况绝对是不好的做法。
顺便说一句,jQuery的工作方式完全相同,它在jquery.js
中定义了$
,然后您可以在自己的脚本文件中使用它。
meskobalazs 解释的很好,如果这两个文件在不同的页面我想你可以使用 HTML5 session/local storage
对不起我的英语。我想知道是否可以将一个文件发送到另一个文件变量?
例如
oneFile.js
var a = true;
twoFile.js
if(a == true) {
alert("hellow");
}
好吧,如果 oneFile.js
在 twoFile.js
之前加载,它将起作用。尽管这种确切的情况绝对是不好的做法。
顺便说一句,jQuery的工作方式完全相同,它在jquery.js
中定义了$
,然后您可以在自己的脚本文件中使用它。
meskobalazs 解释的很好,如果这两个文件在不同的页面我想你可以使用 HTML5 session/local storage