I\'m trying to get innerHTML of a DIV that is located on external page. It is possible to do this using this kind javascript code?
not quite.
Only if the desireed page is on the same domain and same protocol you could try to embed it in an iframe or you could use ajax.
jQuery already has implemented a way to retrieve only a part of an external page ,via ajax:
$.get(url+"#"+id);
, where id
is the div's id. so you would have something like :
var aux = window.location.href.split('/'),
id = 'glr1',
page = 'my_page.html';
$.get(
aux.splice(0,aux.length-1).join('/') + '/' + page + '#' + id,
function(){alert(arguments[0]);}
);