Cross Domain Import into Div
Posted: Mon Jun 18, 2012 12:45 pm
Hi Everyone,
I was wondering if you could give a php newbie some help in implementing this?
This stuff isn't trivial for me, so a little friendly mentoring is appreciated.
What I'm striving for is cross-domain loading of ALL parts of a page into a div. I would prefer to have the php embedded in the file, instead of exterior referenced file - hopefully that's possible.
Using the following, which I found on an old post in this forum, I would like to embed it in my page - any hints on this would be appreciated.
/* I think this gets ALL the contents from a URL & returns in a string variable */
/* usage?? not sure where to put these? */
I then load the content into a specific div "#rwrescue_importwrap" using jquery:
FYI - tried using cross domain ajax script (using Yahoo's YQL) along w/ jQuery get function, but the imported content w/in the div is being shown without html, head, or body tags and scripts are being stripped out on import.
Obviously, page doesn't function or look like the orig, missing images, etc, but I need it to look the same for my users.
I eventually want to have three control sets: (1): be able to allow user to show or hide head, body and footer parts of imported content using checkboxes and (2): ability to step through the content, one element at a time and (3) select a part of the imported content (ie, image, page text, etc) and show outline around that content and then copy just that content to another pane below. Hopefully, I can build these functions w/ jquery once the content is imported using php?, just not sure, any thoughts on approach would be appreciated.
Thanks, Bill
I was wondering if you could give a php newbie some help in implementing this?
This stuff isn't trivial for me, so a little friendly mentoring is appreciated.
What I'm striving for is cross-domain loading of ALL parts of a page into a div. I would prefer to have the php embedded in the file, instead of exterior referenced file - hopefully that's possible.
Using the following, which I found on an old post in this forum, I would like to embed it in my page - any hints on this would be appreciated.
/* I think this gets ALL the contents from a URL & returns in a string variable */
Code: Select all
<?php
function get_url_contents($url) {
$crl = curl_init();
$timeout = 5;
$useragent = “Googlebot/2.1 ( http://www.googlebot.com/bot.html)”;
curl_setopt($crl,CURLOPT_USERAGENT,$useragent);
curl_setopt($crl,CURLOPT_URL,$url);
curl_setopt($crl,CURLOPT_HEADER,TRUE);
curl_setopt($crl,CURLOPT_RETURNTRANSFER,1);
curl_setopt($crl,CURLOPT_CONNECTTIMEOUT,$timeout);
$ret = curl_exec($crl);
curl_close($crl);
return $ret;
}
?>Code: Select all
$initOther = get_url_contents('http://www.somedomain.com/page');
echo $initOtherCode: Select all
$('#rwrescue_importwrap').html($initOther);Obviously, page doesn't function or look like the orig, missing images, etc, but I need it to look the same for my users.
I eventually want to have three control sets: (1): be able to allow user to show or hide head, body and footer parts of imported content using checkboxes and (2): ability to step through the content, one element at a time and (3) select a part of the imported content (ie, image, page text, etc) and show outline around that content and then copy just that content to another pane below. Hopefully, I can build these functions w/ jquery once the content is imported using php?, just not sure, any thoughts on approach would be appreciated.
Thanks, Bill