Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get innerhtml from external page with Javascript

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?

    <script type="text/javascript">
        $(document).ready(function(){
            var html = document.getElementById("glr1").src='/my_page.html'.innerHTML ;
            alert(html);
        });
    </script>
like image 304
andriy Avatar asked Jan 18 '11 20:01

andriy


1 Answers

the jquery load function allows you to specify an element id to load

$('#result').load('ajax/test.html #container');

http://api.jquery.com/load/

like image 167
generalhenry Avatar answered Oct 09 '22 20:10

generalhenry