【发布时间】:2014-07-14 10:51:29
【问题描述】:
我正在使用此代码打开一个新窗口:
Window w = window.open('example2.com', 'example2'); // Consisder than my domain
// is example1.com
这部分代码工作正常并成功打开一个新窗口。比我在加载完成后尝试调用我的函数。
w.onLoad.listen(locationGetter);
这是locationGetter()函数的代码:
locationGetter(Event e) {
Location currentLocation = w.location;
currentHref = currentLocation.href; // currentHref is var defined
} // in main() function
但是这段代码不能很好地工作。每次我运行我的脚本时,currentLocation 和 currentHref 都是空的。一开始我以为问题出在onLoad事件中,所以我尝试在打开窗口后准确调用w.location:
Window w = window.open('example2.com', 'example2');
Location currentLocation = w.location; // still null
我很确定 Window 和 WindowBase 都有 location 属性。请帮助我解决我的问题或提供此任务的替代解决方案。
【问题讨论】: