简体   繁体   中英

How to read the text of an html page with JavaScript?

For a certain project I am working on I have to read the text of a webpage on another domain with Javascript. The webpage will only contain "true" or "false" which I have to get the value of. I was told I could make an iframe and check its innerHTML but that does not seem to work .. ideas? (i would rather not use jquery)

Do you really need to use javaScript - cannot it be done on the server side (server side ie. php would http to the site that you want to get content from and then make actions based on the content on the response)?

Alternatively I looks like simply it is a good candidate for a javascript ajax call to the site you want to read content from - you can do ajax easyly with jquery or many other js frameworks, it is possible to do it without any frameworks as well but it would be more difficult and less proof save. Be worn thought that for cross domain ajax calls you will have problems so you will end up anyway with server side implementation: similar topic here: AJAX cross domain call

impossible, for security reasons.

otherwise i would make an iframe of facebook's login page, and read the html and the stored user/password and hack everybody's account ;) or put the url of one of the pages on the website of your bank account

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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