【问题标题】:Getting the document from the window in javascript while also checking the document has been loaded在 javascript 中从窗口获取文档,同时检查文档是否已加载
【发布时间】:2015-03-30 10:12:25
【问题描述】:

我试图执行以下 javascript 并发现警告框没有显示任何内容。是不是文档没有加载,因此没有填充任何值?以下是供您参考的代码。

function openWindow() {
    window1=window.open('https://www.yahoo.com/');
    var document1=window1.document;
    alert(document1.title);
}

【问题讨论】:

  • 你需要调用函数openWindow()

标签: javascript window document


【解决方案1】:

要在javascript中执行函数,你需要调用函数。

function openWindow() {
    window1=window.open('https://www.yahoo.com/');
    var document1=window1.document;
    alert(document1.title);
}
openWindow()

【讨论】:

  • 我已经在 HTML 代码中放置了 openWindow() 调用。仍然无法理解为什么这不起作用?如果是由于在执行警报之前没有加载文档,那么有什么解决方法吗?
猜你喜欢
  • 2011-01-09
  • 2010-11-01
  • 2014-10-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-02
  • 1970-01-01
相关资源
最近更新 更多