2012-02-04 111 views
-1
As we know, we can use the function `file_get_contents(url)` in PHP to get content of a url.

但是,它可以在JavaScript中可用吗?Javascript:如何获取网址的内容?

The `document.ElementById()` is only valid in current page.

我可以用JS得到divclass在网址是什么?

此外,如果这些内容可以通过PopupBubble显示,我会更感激你。

回答

1

您可以用XMLHttpRequest受可使用CORS

+0

或者换句话说被绕过的Same Origin Policy HTTP请求 - 有多少了解的JavaScript。此答案中缺少的关键字是AJAX – naugtur 2012-02-04 16:20:15

+0

谢谢。我在Chrome扩展中获得了一个API。它可以帮助我跨域访问。 – HectorGuo 2012-02-09 10:04:02