how to grab whole remote page using java script

Started on the old forum in August 2012 · view the original in the archive · old links redirect here

1 reply · 505 views · started 14 years ago · 1 min read

2 participants
krlekhu Newbie · 7 posts #1

how to grab whole remote page using java script.. example i want to grab www.remotesite.com using java script to show its full content on other remote site.. pls help me

something else Fellow · 2,296 posts #2

You cant because of cross site scripting unless you have set permissions on the server you are trying to grab from or you have set permissions like on web browser extensions

Added after 2 minutes:

Here is how to do it if you have got permissions:

<script type="text/javascript">
var xmlhttp = new XMLHttpRequest(); 
xmlhttp.open("GET", "http://remotesite.con", false); 
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); 
xmlhttp.send(null); 
var respon = xmlhttp.responseText; 
document.write(respon);
</script>

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close