get webpage html element values without opening the page in new window or new tab using JavaScript

Just like the title says I need a way to get the HTML of a webpage with out opening it in a new tab or window. I am making a chrome extension that will take element values from one page and append them to another page.

  var htmlObject = gethtml("url"); 

would like some thing like this

Answers 1

  • You can use jQuery to get the content of the webpage:

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    var htmlObject;
    var yourURL = 'url.html';
    $.get(yourURL, function(html) {
      htmlObject = html;
    });


Related Articles