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
.