开发者

How to get the html code from a web page (different domain)?

How can I create a javascript script that a开发者_如何学JAVAllows me to get the html code of a different page from a different domain and allows me to edit and display the code?? Thanks in advance.


Have a look at Cross-domain requests with jQuery (GitHub repo).


This isn't possible in the naive sense because you will get killed by javascript's same domain policy.

Now if you have access to your own web server, you could set up a service that listens for your request which would include a 3rd party URL to fetch. Your service would pull the source for the 3rd party domain and return it as the response to your request. Then you take that response and append it into your editable field.

EDIT: This answer seems to be the same principle as the YQL (Yahoo Query Language) answer that was posted as well.


You can't. Cross domain scripting is not possible... you can also search SO and find many answers to this question.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜