Search code examples
javascripthtmldomcopycopy-paste

How to acsess another page by JS


I just want to copy all texes in shizyab.ir/rand.php and paste it to my html file by javascript. What shoud I do?


Solution

  • This is a version that does not require jquery:

    function insertPage() {
        var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function() {
            var element = document.createElement("div");
            element.innerHTML = this.responseText;
            document.body.appendChild(element);
        };
        xhttp.open("GET", "https://www.shizyab.ir/rand.php", true);
        xhttp.send();
    }
    

    And to run this code: insertPage();