简体   繁体   中英

Load a div from external source

I am trying to load a div from another domain and display it on my site. An <iframe> will not work as the content is dynamically sized and I don't wish to render the entire page, just the content of <div id="content-article">

I have attempted to follow the guide from: http://frinity.blogspot.com/2008/06/load-remote-content-into-div-element.html however after reading the comments it appears to only work for external pages on the same domain.

I don't really care how it is done; php, jquery, ajax or what have you I just don't want to upload the same content to two different domains.

Is there any way to do this?

You could use PHP's DomDocument to parse the HTML of the page that has the div and extract the div you want and then put it into your own content.

What is the URL with the div you want to grab? (Maybe we could write some code to help you pull it out.)

You can't when it should fetch it from external URL. Perhaps you can create a proxy or so and do a jquery.get?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM