admin管理员组文章数量:1389762
How can I create a javascript script that allows 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.
How can I create a javascript script that allows 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.
Share Improve this question asked Jul 28, 2011 at 2:59 Akhil ReddyAkhil Reddy 2577 silver badges17 bronze badges 4- what do you mean by ' allows me to edit and display the code' ? – Jayantha Lal Sirisena Commented Jul 28, 2011 at 3:02
- 1 I want to be able to parse the html and change it a little – Akhil Reddy Commented Jul 28, 2011 at 3:04
- 2 It can be done with a CGI/Perl script on your server and then retrieved by your page to be manipulated with JavaScript. Not posting as an answer since you're not asking about CGI or Perl although it will ultimately get you to the same place. – Sparky Commented Jul 28, 2011 at 3:26
- possible duplicate of Adapt ajax for crossdomain – Quentin Commented Feb 14, 2012 at 15:34
3 Answers
Reset to default 4Have 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.
本文标签: javascriptHow to get the html code from a web page (different domain)Stack Overflow
版权声明:本文标题:javascript - How to get the html code from a web page (different domain)? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744579421a2613827.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论