开发者

Load an external html to string in javascript

Is it possible to load for example google.com to a javascript variable?

var html = "the html of google.com"

Is this possible?开发者_如何转开发

Update: What about in an air application?


Not unless you send the source from the server.

From javascript, it will violate the Same Origin Policy. You can send the request, and you'll get a response, but the response will be empty.


If it's a page in the same domain you're in, then yes. Otherwise, not without some special URL provided by the target domain that sends you pages based on some form of special request.

You can always have your own server fetch the page and forward it to your client.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜