TEEEKST 2'; break; case '#page3' : $page = 'Tekst 3'; break; case '#page4' : $page = 'Tekst 4'; break; } echo $page; ?>
Mój plik index.php wygląda tak:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" href="css/style2.css" type="text/css" media="screen"> <script type="text/javascript"> $(document).ready(function () { //Check if url hash value exists (for bookmark) $.history.init(pageload); //highlight the selected link $('a[href=' + document.location.hash + ']').addClass('selected'); //Seearch for link with REL set to ajax $('a[rel=ajax]').click(function () { //grab the full url var hash = this.href; //remove the # value hash = hash.replace(/^.*#/, ''); //for back button $.history.load(hash); //clear the selected class and add the class class to the selected link $('a[rel=ajax]').removeClass('selected'); $(this).addClass('selected'); //hide the content and show the progress bar $('#content').hide(); $('#loading').show(); //run the ajax getPage(); //cancel the anchor tag behaviour return false; }); }); function pageload(hash) { //if hash value exists, run the ajax if (hash) getPage(); } function getPage() { //generate the parameter for the php script var data = 'page=' + encodeURIComponent(document.location.hash); $.ajax({ url: "loader.php", type: "GET", data: data, cache: false, success: function (html) { //hide the progress bar $('#loading').hide(); //add the content retrieved from ajax and put it in the #content div $('#content').html(html); //display the body with fadeIn transition $('#content').fadeIn('slow'); } }); } </script> </head> <body> <div id="lewy_panel"> <div id="logo"> Logo </div> <div id="menu2"> <ul id="menu"> </ul> </div> <div id="stopka"> Stopka </div> </div> <div id="content"> <!-- Ajax Content --> </div> </body> </html>
Styl CSS natomiast tak:
@charset "utf-8"; /* CSS Document */ body { color:#FFF } #lewy_panel { position: absolute; display: inline-block; width: 294px; height: 100%; background-color:#000; } #logo { position: relative; height: 160px; width: 100%; } #menu2 { position: relative; display: inline-block; padding: 188px 0 0 48px; color:#FFF; } #stopka { position: absolute; bottom: 5px; margin-top: 10px; } #prawy_panel { width: 660px; left: 294px; position: absolute; height: 100%; background-color:#C30; } #loading { background: url(img/load.gif) no-repeat; display:none; } #content { width: 660px; left: 294px; position: absolute; height: 100%; background-color:#C30; font-family:arial; font-size:11px; }
a loader.php tak:
<? switch($_GET['page']) { case '#page1' : $page = 'Tekst 1 '; break; case '#page2' : $page = '<b>TEEEKST 2</b>'; break; case '#page3' : $page = 'Tekst 3'; break; case '#page4' : $page = 'Tekst 4'; break; } ?>
Proszę o pomoc w prawidłowym użyciu skryptu.