简体   繁体   English

在javascript中加载页面而不打开它

[英]Load page in javascript without opening it

I'd like to load the contents of a page in javascript without actually opening it. 我想在javascript中加载页面的内容而不实际打开它。 I want to use it so I can load a page and scan some of its elements to see if it should actually be opened in a new window/tab before doing the opening itself. 我想使用它,所以我可以加载一个页面并扫描它的一些元素,以确定它是否应该在开放本身之前在新窗口/选项卡中实际打开。

How can I do that? 我怎样才能做到这一点?

You can do this using the XMLHttpRequest object. 您可以使用XMLHttpRequest对象执行此操作。

This is subject, however, to cross-domain scripting limitations. 但是,这受制于跨域脚本限制。

Read more about it: 阅读更多相关信息:

Load it in an Ajax call. 将其加载到Ajax调用中。

With jQuery: 使用jQuery:

$.ajax({
  url: 'http://your_page_url',
  success: function( data ) {
    // process data (which is actually your page contents)
  }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM