【发布时间】:2015-12-09 19:57:53
【问题描述】:
这里是window:
所以现在,当我向下滚动时(孩子们以与上面显示的方式相同的方式出现,一直很长),我看到了我想要的:
但我只是无法访问它。为什么?
这里的代码,在一个位于 js 文件夹中的函数中:
function update_match(slot, match, s) {
$("#match" + slot + " i").text(match);
console.log(window);
console.log(window.saves1); // undefined
console.log(window.external.saves1); // undefined
(slot == 1) ? window.saves1.item = s : window.saves2.item = s;
}
变量是这样创建的:
function set_global(name, pos, ab, needSave, s) {
window.saves1 = {item: s};
window.saves2 = {item: s};
}
在 js/main.js 文件中。
文件结构是这样的:
index.php (where the php code runs and calls update_match())
js - main.js
- read_match.js
【问题讨论】:
-
你什么时候调用这个
update_match函数,从哪里来的? Remember that theconsoleis lying -
你有多个 iframe 吗?
-
我在 index.php 的底部调用它@Bergi。在index.php文件所在的目录下,js文件夹也是如此。
-
@LucianDepold 据我所知,但我使用的是 jquery mobile,可能会导致问题吗?
-
不,我不这么认为
标签: javascript global-variables undefined global scopes