1

Is it possible to get source code of any webpage with javascript at client side? With AJAX maybe?

But I need that the server I am downloading the url from does see the IP of the client.. with AJAX it will show my script server IP, right?

Thank you in advance.

3 Answers 3

3

Javascript can not fetch items outside of its domain.

An AJAX query is just a normal request done asynchronously. Everything that happens in a real request will happen in an AJAX request.

Regarding the IP thing, the request is coming from the client. Since Javascript is client based, so you will see the client's IP in the request.

Sign up to request clarification or add additional context in comments.

Comments

2

It should be possible to do so if you implement a service on your server that does the retrieval. So your AJAX-request would call a URL like the following:

http://myownserver.com/getContent?url=theotherserver.com

That way you could get around the XSS-security protection of your browser, but the remote server will then see the IP of your own server instead of that of the client.

Comments

0

Firstly, this is known as cross-site scripting (XSS) and is considered a security risk, so current browsers do not allow it.

More generally, if your page included a reference (an image, perhaps) sourced from server X, then server X would see the client's apparent IP, which could be a proxy server in their ISP, or their real IP.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.