tags:

views:

35

answers:

5

is it possible to read or extract html/text from a different .html page using jquery?

this what i would like to read and display in a different page

                    <div class="newsItemContent"> 
                      <h1 class="title"> 
                        heading 1
                      </h1>
                      content 1 content 1 content 1 content 1 
                    </div>

                   <div class="newsItemContent"> 
                      <h1 class="title"> 
                        heading 2
                      </h1>
                      content 2 content 2 content 2 content 2 
                    </div>

thanks

+2  A: 

If the page is on the same domain/server you could try to access it through AJAX

Prot0
+1  A: 

Most certainly. The $.get() method will do what you want.

Pat
A: 

Yup you can use ajax for this. Or if it's on a different domain JSONP.

Ken Struys
A: 

If the second page is within an iframe, you could access it with something like:

$('#iframeID').contents().html();
Joey C.
A: 

You can extract from another page using the load method thus $('#targetElement').load('page.htm #container') syntax.

Lazarus