Jump to content

What is this called? Or how is it done?


Spring

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.