Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<title> Remote Web page source code read </title>
<style type= "Text/css" >
/* Page Font style * *
Body, TD, input, TEXTAREA {
font-family:arial;
font-size:12px;
}
</style>
<script type= "Text/javascript" >
Used to create a XMLHttpRequest object
function Createxmlhttp () {
According to window. Whether the XMLHttpRequest object exists using a different creation method
if (window. XMLHttpRequest) {
XmlHttp = new XMLHttpRequest (); Firefox, Opera and other browsers support the creation of the way
} else {
XmlHttp = new ActiveXObject ("Microsoft.XMLHTTP");//ie browser-supported creation
}
}
Get the Remote Web page source code directly from the XMLHttpRequest object
function GetSource () {
var url = document.getElementById ("url"). Value; Get Destination Address information
Prompt user for input when address is empty
if (url = = "") {
Alert ("Please enter a Web address.") ");
Return
}
document.getElementById ("source"). Value = "Loading ..."; Prompt is loading
Createxmlhttp (); Creating XMLHttpRequest Objects
Xmlhttp.onreadystatechange = WriteSource; Set callback function
Xmlhttp.open ("Get", url, True);
Xmlhttp.send (NULL);
}
Write Remote Web page source code to page text area
function WriteSource () {
if (xmlhttp.readystate = = 4) {
document.getElementById ("source"). Value = Xmlhttp.responsetext;
}
}
</script>
<body>
<div>
Address: <input type= "text" id= "url" >
<input type= "button" onclick= "GetSource ()" value= "Get Source" >
</div>
<textarea rows= "cols=" id= "source" ></textarea>
</body>