tags:

views:

47

answers:

3

I'm try to figure out if there is a way to pass the page source across domains using javascript or another method each time a page is loaded? I know in javascript I can output the page source in to variables using the code below, but how would I go about passing it over to a different domain?

var head_src = document.head.innerHTML;
var body_src = document.body.innerHTML;

Can anyone point me in to the right direction? It seems every method I've tried or researched doesn't work correctly or has a lot of issues and I'm running out of ideas. Thanks in advance.

EDIT MORE INFO BELOW

Imagine that I have two websites on different servers. Website A is where the source data needs to be sent to and Website B is a website that users browse and I want to collect the source of each page they view and post it to Website A. I have access to both servers and I was hoping that I could add JS code on Website B that will pass the data over.

A: 

Use your server-side language of choice to make the request and store the data in javascript. This proxying method is a common way of grabbing data from different domains.

Stefan Kendall
I dont want to make the request from server A. I want server b (the page the user is browsing) to save the page src in to variables and post it back to sever A.
mike
Capture the dom, pass it as a POST request to a proxy on the same domain, and have the proxy make the request.
Stefan Kendall
A: 

Just capture the source using the method you described then use JS to post it in a form (ie, POST variable).

SpliFF
A: 

I don't believe you'll be able to do this client-side because innerHTML produces different output depending on the browser. Various versions of Internet Explorer especially won't respect the original source code - you'll find unquoted attributes, mixed case tags and extra markup inserted all over the place.

The only solution I can think of is to buffer the HTML output from server B into an escaped form field in the output page and have that posted across to server A. How you do the buffering will depend on what platform server B is running.

Karl B