开发者

Best method for posting page source across domains?

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 wo开发者_StackOverflow社区rk 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.


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜