Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
Posted
Updated 9-Apr-10 5:27am
v3

You're going to have to write your own web browser.
 
Share this answer
 
Try createrequest:

<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);
    }


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.
 
Share this answer
 
v4
Comments
ishant7890 2-Jul-10 1:20am    
how n where to run dis code...m new to dis

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900