Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-05-2008, 05:33 PM   PM User | #16
itsallkizza
Senior Coder

 
Join Date: Oct 2008
Location: Long Beach
Posts: 1,196
Thanks: 36
Thanked 164 Times in 164 Posts
itsallkizza will become famous soon enough
The bottom bar IS refreshing (and being rebuilt by code on refresh) whenever the user goes to a new page.

For example, if I were to click on an app (like MobWars) from my main profile page, the page would refresh and the bottom toolbar would appear to remain the same, but in fact it also would be refreshed.
__________________
Feel free to e-mail me if I forget to respond ;)
ohsosexybrit@gmail.com

Last edited by itsallkizza; 12-05-2008 at 05:36 PM..
itsallkizza is offline   Reply With Quote
Old 12-06-2008, 09:21 AM   PM User | #17
panther21001
New to the CF scene

 
Join Date: Mar 2006
Location: Mid-Missouri, USA
Posts: 8
Thanks: 2
Thanked 0 Times in 0 Posts
panther21001 is an unknown quantity at this point
How about we contact a lead Facebook developer to take part in this conversation?

Or, alternatively, someone could easily disassemble the Facebook and have proof of what is really going on.

I would enter my opinion, but at this time I doubt it really matters.

The person who started the thread asked a question. I think the only suitable thing to respond with is a plausible answer. So animedude123, you have a few options to accomplish this; read the above posts for reference to these ideas, and try to ignore the silly fights that occurred intermittently.

Personally, I would like to think this is sufficient proof to backup hjb's theory:

Right after the <body> tag:
Code:
<iframe id="channel_iframe"></iframe>
And the loader:
Code:
onloadRegister(function() {channelManager.iframeLoad("\/iframe\/10?r=http%3A%2F%2Fstatic.ak.fbcdn.net%2Frsrc.php%2Fz2F1W%2Flpkg%2Fb5q02ww8%2Fen_US%2F141%2F134751%2Fjs%2F97qxpm42mnksoos8.pkg.js&r=http%3A%2F%2Fstatic.ak.fbcdn.net%2Frsrc.php%2FzB82G%2Fl%2F2937wik3%2Fnu_ll%2F134020%2Fjs%2Fpresence%2Fiframex.js", "channel05", 80, 1);});
panther21001 is offline   Reply With Quote
Old 12-06-2008, 11:10 AM   PM User | #18
hjb
New to the CF scene

 
Join Date: Nov 2008
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
hjb is an unknown quantity at this point
Ok, a possible solution to your problem....

1) add an onclick event to all <a> tags for which you want to spoof page load. something like:

Code:
<a href="/real_url/page.html" onclick="spoofPageLoad(this);">link text</a>
2) create the javascript function spoofPageLoad. something like

Code:
function spoofPageLoad(link)
{
	// get the url to spoof
	var url = link.url;

	// create an iframe element
	var iframe = document.createElement('IFRAME');

	// create a unique id for the iframe
	var id = (new Date).getTime();

	// set the id to the iframe
	iframe.id = id;

	// add the iframe to the body
	document.body.appendChild(iframe)

	// set the url of the iframe
	iframe.src = 'http://example.com/getPageContent.php?id='+id+'&url='+url;

	// cancel default link click
	return false;
}
3) Create the backend php to send the right page back

Code:
<?php

if($_GET['id'] && $_GET['url'])
{
	// load the page content with a FAKE FUNCTION THAT NEEDS CREATING
	$html = addslashes(loadPageHtml($_GET['url']));

	// output a page that will fire the update page function in the parent frame

?>
<html>
	<head>

<script type="text/javascript">
	function fireUpdate()
	{
		window.top.window.updateContent("<?php print $_GET['url']; ?>", "<?php print $html; ?>", <?php print $_GET['id']; ?>);
	}
</script>

	</head>
	<body onload="fireUpdate();"></body>
</html>
<?php

}

?>
4) create the javascript updateContent function

Code:
function updateContent(url, html, id)
{
	// get the content div
	var content = document.getElementById('content');

	// set innerHTML (update the page)
	content.innerHTML = html;

	// update the hash part of the url for browser history and possible bookmarking
	window.location.hash = url;

	// get reference to the iframe
	var iframe = document.getElementById(id);

	// set a timeout to then remove the iframe - we do this because IE has issues with iframes still loading after remove
	setTimeout(function()
	{
		document.body.removeChild(iframe);

	},200);

	return false;
}
*NOTE* - I haven't tested any of the above code and I know there are issues:

* You need to write a php function to get the actual page html from database or file
* You need to write code to catch a user returning with a page address in the hash part of the url (ala Facebook) - true bookmarking with hash

All other parts of the page (including footer) will be untouched


.
hjb is offline   Reply With Quote
Old 12-28-2008, 03:44 PM   PM User | #19
tristanleboss
New to the CF scene

 
Join Date: Dec 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
tristanleboss is an unknown quantity at this point
I just want to confirm that the Facebook bar doesn't reload on page change.
If you want to test by yourself, install Firefox 3 and Firebug extension (www.getfirebug.com).

Once on a Facebook page, modify the HTML of an item of the bar* and change page ... the change is still there. This kind of change made by the user, change Facebook is not aware of, can't be transported on an new page.

* For example, in the console tab, type :
document.getElementById('presence_applications_tab').style.backgroundColor='red';
That line will change the bakcgound color of the "Application" button to red.

Also if you go to the HTML tab and unfold "body" and change page, you will see an iframe briefly appearing at the bottom of the tree.
tristanleboss is offline   Reply With Quote
Old 01-07-2009, 05:55 PM   PM User | #20
theor74
New to the CF scene

 
Join Date: Jan 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
theor74 is an unknown quantity at this point
hjb, when I try your code out, the javascript function spoofPageLoad, the link.url says undefined. This is in FireFox.
theor74 is offline   Reply With Quote
Old 01-08-2009, 12:40 PM   PM User | #21
hjb
New to the CF scene

 
Join Date: Nov 2008
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
hjb is an unknown quantity at this point
Quote:
Originally Posted by theor74 View Post
hjb, when I try your code out, the javascript function spoofPageLoad, the link.url says undefined. This is in FireFox.
I know. The code doesn't work. I stated that above.

However....

replace link.url

with link.href

and retry. The rest is up to you.
hjb is offline   Reply With Quote
Old 01-27-2009, 12:37 AM   PM User | #22
jeff.spark
New to the CF scene

 
Join Date: Jan 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
jeff.spark is an unknown quantity at this point
Firefox and MSIE both behave similarly in that they do -not- reload the page on navigation.

Chrome, Safari and Opera on the other hand reload the page.

I just wanted to point this out as it doesn't seem like anyone has mentioned it yet.

A side note, it's interesting and puzzling that Facebook would only implement this in two browsers and not in the others. Perhaps there are cross domain JavaScript issues we do not know about?

Edit: "cross domain JS" referring to the iframe solution
jeff.spark is offline   Reply With Quote
Old 04-14-2009, 12:51 PM   PM User | #23
Sumez
New to the CF scene

 
Join Date: Apr 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Sumez is an unknown quantity at this point
Yeah, I was wondering why they load the page into an iFrame, instead of "just" using AJAX? It doesn't seem like the best solution to me, but there must be a reason for it. Any theories?

After all, Facebook are the biggest AJAX whores you can find. :P (but so am I, I love the possibilities it gives you)
Sumez is offline   Reply With Quote
Old 04-15-2009, 09:56 AM   PM User | #24
hjb
New to the CF scene

 
Join Date: Nov 2008
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
hjb is an unknown quantity at this point
Hi Sumez,

pretty sure that Facebook have chosen iframes over ajax because web sites that use AJAX won't work on IE when ActiveX controls are disabled in the security settings.

I really don't know how I ended up with negative reputation for this thread!? Personally I thought I had been accurate, objective and helpful.
hjb is offline   Reply With Quote
Users who have thanked hjb for this post:
chaoticlife (04-16-2009)
Old 04-15-2009, 12:10 PM   PM User | #25
Sumez
New to the CF scene

 
Join Date: Apr 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Sumez is an unknown quantity at this point
Definitely, the information you provided here has definitely been very useful. And correct, unlike a lot of other claims in this thread.

So does that mean Facebook NEVER uses AJAX? For the smaller functions as well, such as the "Like" buttons?
That's a surprise to me, I was convinced it was practically made up of AJAX - but I guess the end result is the same.
Sumez is offline   Reply With Quote
Old 04-15-2009, 06:51 PM   PM User | #26
itsallkizza
Senior Coder

 
Join Date: Oct 2008
Location: Long Beach
Posts: 1,196
Thanks: 36
Thanked 164 Times in 164 Posts
itsallkizza will become famous soon enough
Using iframes is AJAX. If you want to separate XMLHTTPRequests from Iframe usage or other methods of AJAX, be specific.
__________________
Feel free to e-mail me if I forget to respond ;)
ohsosexybrit@gmail.com
itsallkizza is offline   Reply With Quote
Old 04-16-2009, 09:21 AM   PM User | #27
hjb
New to the CF scene

 
Join Date: Nov 2008
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
hjb is an unknown quantity at this point
itsallkizza is correct. Ajax also includes iframe requests however, I know what you meant.

Facebook uses iframe and XMLHTTPRequests all over the place and all the time. If you install 'firebug' for firefox and click the console tab you can see all the requests flying.

I can only think they use XMLHTTPRequests for things that are 'nice have' items but not required for functionality, where they use iframes. For example, XMLHTTPRequests is used for chat, notifications and inbox updates, on page status updated.
hjb is offline   Reply With Quote
Old 04-16-2009, 10:20 AM   PM User | #28
sybil6
Regular Coder

 
Join Date: Jul 2006
Posts: 399
Thanks: 33
Thanked 7 Times in 7 Posts
sybil6 can only hope to improve
must be an ajax request called thru php get superglobal
sybil6 is offline   Reply With Quote
Old 04-16-2009, 08:28 PM   PM User | #29
chaoticlife
New to the CF scene

 
Join Date: Apr 2009
Posts: 2
Thanks: 2
Thanked 0 Times in 0 Posts
chaoticlife is an unknown quantity at this point
Thanks for the clear explanation, hjb.
chaoticlife is offline   Reply With Quote
Old 08-10-2009, 11:43 PM   PM User | #30
SJF
New to the CF scene

 
Join Date: Jun 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
SJF is an unknown quantity at this point
An interesting note.

First and foremost, sorry for the bump - but this is an interesting addition to this discovery of the way Facebook changes pages.

Code:
javascript:(function(){var%20i=0,r=function(n){return%20Math.floor(Math.random()*n)},f=document.getElementsByTagName('body')[0].getElementsByTagName('*'),o=function(e){return%20typeof(e.style)=='object'&&e.tagName!='SCRIPT'},s=function(){while(!o(e=f[r(f.length)])){}return%20e.style};while(i++<5){s().display=r(2)?'block':'inline';s().position=r(2)?'absolute':'relative';s().margin=r(2)?'0':'1em';s().padding=r(2)?'0':'1em';s().width=r(2)?'':'auto';}})();
That code is from IE6ify, a funny little joke for designers that if you put that code into a bookmark on your bookmark toolbar and keep clicking it, it randomly screws up your page.

Now why is this relevant?

I was on this thread a couple days ago, wondering exactly how Facebook DOES change its pages. And after sifting through the very caddy immature responses, and hallow threats to report to a MOD (for no reason) ... I discovered there was a misconception. On one end, people were claiming that it is impossible, that the bottom bar refreshes, as does the whole page. On the other end, (the right end), people were saying no it doesn't, it uses an iframe to bring in the content, etc, notice the hash in the address bar.

With the IE6ify script I included above, you can CLEARLY SEE it does NOT refresh the page. In fact, even in Safari it does not refresh it. YES, I know, it does in Chrome & IE, but those are irrelevant to this case because it does NOT in Firefox and Safari, making the question remain, how DO they do it? I think hjb provided a very good amount of information toward this, and want to comment quickly on that.

First let me preface what I'm about to say with IDGAF about my 'rep' or 'my post being removed' with this... but I think it's absolute BULL that there is SO MUCH immaturity on forums these days. We should all be here to help each other out. That's it. I absolutely HATE when people state "facts" and shut out any other suggestion from anyone else. Its absolutely ridiculous.

With that said, happy coding!
SJF is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:18 AM.


Advertisement
Log in to turn off these ads.