开发者

dom question: getting the full sourcode from a html document

i'm trying开发者_开发问答 things out with a html document's dom (under visualbasic6) and i was wondering: how can i get the full html sourcecode including all headers?

is there something like document.all.value?

thanks


If all you have is a DOM, there is no way to retrieve the original source, much less the response headers. It's gone. The DOM is what was generated from the source, which was thrown away thereafter.

If you must have the original source and headers, you will have to fetch it again from the server, using the location object to get the URL. For example from inside a web page script:

var req= 'XMLHttpRequest' in window? new XMLHttpRequest() : new ActiveXObject('MSXML2.XMLHttpRequest');
req.onreadystatechange= function() {
    if (this.readyState===4) {
        alert('Headers: '+this.getAllResponseHeaders());
        alert('Body: '+this.responseText);
    }
};
req.open('get', location.href);
req.send(null);

Clearly this will only work for a page generated from a GET request.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜