Chechu, here's something you can experiment with. With IE and Google Chrome it only works online. Demo here.
index.html:
Code:
<!doctype html>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>From framesets to hashchange</title>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<style>
body {font-family: verdana; font-size: 12px}
</style>
</head>
<body>
<!-- HEADER: -->
<div style="position: fixed; left:0;top:0;right:0;height: 25%; background: yellow; text-align: center">
<div id="message" style="width: 200px; height: 100px; background:#dedede; margin:auto; margin-top: 10px; padding-left: 5px; padding-right: 5px">
<div style="float: right; cursor: pointer" onclick="document.getElementById('message').style.display='none'; document.getElementById('get_message').style.display='block'">X</div><br><br>
Hallo zuiderbuur, hoe gaat het?<br>
Hallo zuiderbuur, hoe gaat het?<br>
</div>
<div id="get_message" style="display: none; width: 200px; height: 40px; background:#dedede; margin:auto; margin-top: 10px; padding-left: 5px; padding-right: 5px">
Klik <a href="javascript: void()" onclick="document.getElementById('message').style.display='block'; document.getElementById('get_message').style.display='none'">here</a> to get the original message
</div>
</div>
<div style="position: absolute; top: 100px">
<a href="#home.html">Home</a>
<a href="#page1.html">Page 1</a>
<a href="#page2.html">Page 2</a>
</div>
<!-- etc. -->
<!-- DIV FOR THE CONTENT PAGES HERE: -->
<div id="content_pages" style="position: absolute; top: 26%; margin-top: 20px"></div>
<script>
function hash_change()
{
$('#content_pages').load(location.hash.substring(1,location.hash.length))
$('*').scrollTop(0)
}
window.onhashchange=hash_change;
window.onload=hash_change;
if(window.location.hash=='')window.location.replace('#home.html')
</script>
</body>
</html>
home.html
Code:
<!doctype html>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>From framesets to hashchange</title>
<script src="orph.js"></script>
</head>
<body>
This is home<br>
If you hide the grey box in the header, it will be gone for each page of this site.
</body>
</html>
page1.html:
Code:
<!doctype html>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>From framesets to hashchange</title>
<script src="orph.js"></script>
</head>
<body>
This is page 1.<br>
If you hide the grey box in the header, it will be gone for each page of this site.
</body>
</html>
page2.html:<br>
Code:
<!doctype html>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>From framesets to hashchange</title>
<script src="orph.js"></script>
</head>
<body>
This is page 2<br>.
If you hide the grey box in the header, it will be gone for each page of this site.
</body>
</html>
orph.js:<br>
Code:
function orph()
{
//dont't allow pages to show as 'orphans' (without the main page). The main page is called 'index.html' here
if(window.location.hash=='')
{
{window.location='index.html#'+document.URL.substring(document.URL.lastIndexOf('/')+1, document.URL.length);}
}
}
if ( typeof window.addEventListener != "undefined" )
window.addEventListener( "load", orph, false );
else if ( typeof window.attachEvent != "undefined" )
window.attachEvent( "onload", orph );
else {
if ( window.onload != null ) {
var oldOnload = window.onload;
window.onload = function ( e ) {
oldOnload( e );
orph();
};
}
else
window.onload = orph;
}
Bookmarks