Spring Posted October 22, 2011 Share Posted October 22, 2011 It's a little difficult for me to explain but, when a website loads another site (For example with Curl or something) How is the site able to keep a header or some part of original site 'attached' to the site they loaded..for example, say you're redirected, the site you redirected to loads, but you still see the site you redirected from header on at the top of the page. How is this done? What is it called? Do you need me to clear it up a bit better? I can try to find an example. Quote Link to comment https://forums.phpfreaks.com/topic/249605-what-is-this-called-or-how-is-it-done/ Share on other sites More sharing options...
Spring Posted October 22, 2011 Author Share Posted October 22, 2011 Sorry meant to edit not quote.. Quote Link to comment https://forums.phpfreaks.com/topic/249605-what-is-this-called-or-how-is-it-done/#findComment-1281406 Share on other sites More sharing options...
xyph Posted October 22, 2011 Share Posted October 22, 2011 I-frames/frames are probably the cleanest method. Any other solution would involve heavy parsing to maintain clean code Quote Link to comment https://forums.phpfreaks.com/topic/249605-what-is-this-called-or-how-is-it-done/#findComment-1281414 Share on other sites More sharing options...
xtopolis Posted October 22, 2011 Share Posted October 22, 2011 I've seen what you're talking about, and there are various ways to do this, so I'll speak in general terms. If you have a specific example, you could investigate the source code yourself, or link it here and nicely ask someone to break down the "technologies" used. In general, to display one "website" as a subpage of another: You can use frames/iframes. //not very widely used You can use javascript(ajax) and divs. //more common I'm not 100% on the technologies, but I think they either load the page in another div, or even use javascript injection into the destination page. Quote Link to comment https://forums.phpfreaks.com/topic/249605-what-is-this-called-or-how-is-it-done/#findComment-1281415 Share on other sites More sharing options...
xyph Posted October 22, 2011 Share Posted October 22, 2011 With JavaScript injection, you will have to inject the head and body separately to maintain standards-compliant code. You will also have to watch out for importing JavaScript from external sites that conflict with functions/variables declared in your own JavaScript. Quote Link to comment https://forums.phpfreaks.com/topic/249605-what-is-this-called-or-how-is-it-done/#findComment-1281418 Share on other sites More sharing options...
sphinx Posted October 22, 2011 Share Posted October 22, 2011 Use Ajax. Keep the header on your web page, then insert the ajax DIV below, and in the loader file, place a header redirect. If you want code let me know. Quote Link to comment https://forums.phpfreaks.com/topic/249605-what-is-this-called-or-how-is-it-done/#findComment-1281419 Share on other sites More sharing options...
Spring Posted October 22, 2011 Author Share Posted October 22, 2011 Use Ajax. Keep the header on your web page, then insert the ajax DIV below, and in the loader file, place a header redirect. If you want code let me know. Hey sounds good! And yeah, an example would be fabulous!! Quote Link to comment https://forums.phpfreaks.com/topic/249605-what-is-this-called-or-how-is-it-done/#findComment-1281420 Share on other sites More sharing options...
sphinx Posted October 22, 2011 Share Posted October 22, 2011 Script for web page: <script type="text/javascript"> function Ajax() { var $http, $self = arguments.callee; if (window.XMLHttpRequest) { $http = new XMLHttpRequest(); } else if (window.ActiveXObject) { try { $http = new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) { $http = new ActiveXObject('Microsoft.XMLHTTP'); } } if ($http) { $http.onreadystatechange = function() { if (/4|^complete$/.test($http.readyState)) { document.getElementById('ReloadThis').innerHTML = $http.responseText; setTimeout(function(){$self();}, 6000) } }; $http.open('GET', 'random.php' + '?' + new Date().getTime(), true); $http.send(null); } } </script> Also include this in the 'body' which is the additional loader before the above takes effect. <script type="text/javascript"> //ADDITIONAL LOADER BEFORE ABOVE LOADER CURRENTLY AT 6000. setTimeout(function() {Ajax();}, 1000); </script> then add random.php and add the code you want it to load. DIV <div id="ReloadThis">THIS TEXT will disappear when it has loaded</div> Quote Link to comment https://forums.phpfreaks.com/topic/249605-what-is-this-called-or-how-is-it-done/#findComment-1281422 Share on other sites More sharing options...
Spring Posted October 22, 2011 Author Share Posted October 22, 2011 Script for web page: <script type="text/javascript"> function Ajax() { var $http, $self = arguments.callee; if (window.XMLHttpRequest) { $http = new XMLHttpRequest(); } else if (window.ActiveXObject) { try { $http = new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) { $http = new ActiveXObject('Microsoft.XMLHTTP'); } } if ($http) { $http.onreadystatechange = function() { if (/4|^complete$/.test($http.readyState)) { document.getElementById('ReloadThis').innerHTML = $http.responseText; setTimeout(function(){$self();}, 6000) } }; $http.open('GET', 'random.php' + '?' + new Date().getTime(), true); $http.send(null); } } </script> Also include this in the 'body' which is the additional loader before the above takes effect. <script type="text/javascript"> //ADDITIONAL LOADER BEFORE ABOVE LOADER CURRENTLY AT 6000. setTimeout(function() {Ajax();}, 1000); </script> then add random.php and add the code you want it to load. Thanks! Really appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/249605-what-is-this-called-or-how-is-it-done/#findComment-1281423 Share on other sites More sharing options...
sphinx Posted October 22, 2011 Share Posted October 22, 2011 no problem, check post again, added additional info. Quote Link to comment https://forums.phpfreaks.com/topic/249605-what-is-this-called-or-how-is-it-done/#findComment-1281424 Share on other sites More sharing options...
watsmyname Posted October 23, 2011 Share Posted October 23, 2011 or this may work as well i m not sure. <div>your header</div> <div><?php file_get_contents("http://www.othersite.com")?></div> hope this helps watsmyname Quote Link to comment https://forums.phpfreaks.com/topic/249605-what-is-this-called-or-how-is-it-done/#findComment-1281486 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.