Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to read another url's dom structure?

Tags:

javascript

Obviously modifying it would be out of the question.

But you would think just reading it should not be a problem?

If i have my .js running on someone's system and I want to analyze the DOM of another URL , client side, is there a way to do this?

Something simple like pull the title tag or pull the url...maybe load the site into an iframe to accomplish this?

like image 864
CS_2013 Avatar asked May 21 '12 19:05

CS_2013


Video Answer


1 Answers

You can do this using xmlhttp

function getSourceAsDOM(url)
{
    xmlhttp=new XMLHttpRequest();
    xmlhttp.open("GET",url,false);
    xmlhttp.send();
    parser=new DOMParser();
    return parser.parseFromString(xmlhttp.responseText,"text/html");      
}
like image 101
Megachip Avatar answered Nov 14 '22 08:11

Megachip