在Web浏览器显示HTML之前捕获HTML [英] Capture HTML before the webbrowser displays it
问题描述
我需要捕获服务器在发送请求时发送给我的HTML.我修改了HTML,然后重新发送到Web浏览器以显示它.您能给我一些如何做的想法吗?谢谢. :)
附言:对不起,我没有仔细解释我想做的事情.
例如,我使用IE浏览互联网,并且我想编写一个程序来捕获应该由IE获取的HTML.之后,我修改HTML,然后将其发送回IE:doh::doh::doh::doh::doh::doh:
I need to capture the HTML that the server sent to me when sending a request. And I revise the HTML, then resend to the webbrowser to display it. Could you please give me some ideas on how to do it? Thanks. :)
P.S.: Sorry I didn''t explain what I want to do carefully.
For example, I use IE to surf the internet and I want to write a program to capture the HTML which is supposed to be got by IE. After that, I revise the HTML, then send it back to IE :doh: :doh: :doh: :doh: :doh: :doh:
推荐答案
You "将不得不编写自己的Web浏览器.
You''re going to have to write your own web browser.
尝试createrequest
:
Trycreaterequest
:
<removed language="javascript" type="text/javascript" />
var request;
//var h=0;
function createrequest()
{
request=null;
request = new ActiveXObject("Msxml2.XMLHTTP";);
// this will work only in IE other browser''s object are different
if (request == null)
alert("Error Creating Object";);
}
function updatepage()
{
if (request.readyState == 4)
{
var rate;
rate = request.responseText;
// this rate var has got all the html text returned from server
}
}
function GetRate()
{
var fullurl;
createrequest();
fullurl = "ABC.HTML";
request.open("GET", fullurl, true);
request.onreadystatechange=updatepage;
request.send(null);
}
尝试以下JavaScript:
获得HTML后,对其进行修改并写入DIV
(ID应为"Result
")对象,如:
Try this JavaScript:
After you get the HTML, modify it and write in a DIV
(ID should be "Result
") object like:
document.getElementById("Result").innerHTML=rate;
我希望这能解决您的目的.
如果有帮助,请回复?
此代码是特定于浏览器的.在网上搜索以找到浏览器及其对象名称.
I hope this will solve your purpose.
Please reply if this is helpful?
This code is browser specific. Search on the web to find the browser and their object names.
这篇关于在Web浏览器显示HTML之前捕获HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!