Copy code The code is as follows: Remote web page source code reading <br>/* Page font style*/ <br>body, td, input, textarea { <br>font-family:Arial; <br>font-size:12px; <br>} <br> <br>//Used to create an XMLHttpRequest object<br>function createXmlHttp() { <br>//Use different creation methods depending on whether the window.XMLHttpRequest object exists<br>if (window.XMLHttpRequest) { <br>xmlHttp = new XMLHttpRequest(); //Creation method supported by FireFox, Opera and other browsers <br>} else { <br>xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); //Creation method supported by IE browser Method<br>} <br>} <br>//Get the remote web page source code directly through the XMLHttpRequest object<br>function getSource() { <br>var url = document.getElementById("url").value; // Get the target address information<br>//Prompt the user to input when the address is empty<br>if (url == "") { <br>alert("Please enter the web page address."); <br>return; <br> } <br>document.getElementById("source").value = "Loading..."; //Prompt is loading<br>createXmlHttp(); //Create XMLHttpRequest object<br>xmlHttp.onreadystatechange = writeSource; // Set the callback function <br>xmlHttp.open("GET", url, true); <br>xmlHttp.send(null); <br>} <br>//Write the remote web page source code into the page text area<br>function writeSource() { <br>if (xmlHttp.readyState == 4) { <br>document.getElementById("source").value = xmlHttp.responseText; <br>} <br>} <br>< /script> <br></head> <br><body> <br><h1>Remote web page source code reading</h1> <br><div> <br>Address: < input type="text" id="url"> <br><input type="button" onclick="getSource()" value="Get source code"> <br></div> <br> <textarea rows="10" cols="80" id="source"></textarea> <br></body> <br></html> <br> </div>