Reputation: 1
Im programing website, I use this code before and it works perfect but now when I want to use some flash parts its realoading all website everytime I click link.
Source Code:
<!DOCTYPE html>
<html>
<head>
<title>Hot King Staff</title>
<meta charset="utf-8">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="tagi" />
<meta name="Author" content="Filip Jóźwiak" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquB895.js"></script>
</head>
<body>
<div id="cialo">
<?php include('header.php'); ?>
<?php include('menu.php'); ?>
</div>
<div id="content">
<?php
$id = isset($_GET['id']) ? $_GET['id'] : '';
switch($id)
{
case '':
include 'content/news.php';
break;
case '2':
include 'content/dogs.php';
break;
case '3':
include 'content/training.php';
break;
case '4':
include 'content/links.php';
break;
case '5':
include 'content/contact.php';
break;
default:
echo 'Taka strona nie istnieje';
break;
}
?>
</div>
</body>
</html>
and this is code of my menu.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<a href="index.php"><div id="news"></div></a>
<a href="index.php?id=2"><div id="dogs"></div></a>
<a href="index.php?id=3"><div id="training"></div></a>
<a href="index.php?id=4"><div id="links"></div></a>
<a href="index.php?id=5"><div id="contact"></div></a>
</body>
</html>
Can you help me with that, thanks for response.
Upvotes: 0
Views: 64
Reputation: 72
first: you are including ur menu, why did you set:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<a href="index.php"><div id="news"></div></a>
<a href="index.php?id=2"><div id="dogs"></div></a>
<a href="index.php?id=3"><div id="training"></div></a>
<a href="index.php?id=4"><div id="links"></div></a>
<a href="index.php?id=5"><div id="contact"></div></a>
</body>
</html>
??? if you wnt to include this, than include just your menu:
<a href="index.php"><div id="news"></div></a>
<a href="index.php?id=2"><div id="dogs"></div></a>
<a href="index.php?id=3"><div id="training"></div></a>
<a href="index.php?id=4"><div id="links"></div></a>
<a href="index.php?id=5"><div id="contact"></div></a>
If you want to change a specific part of the site without refreshing it completly you could use jQuery
In your main page add this piece of jquery but notice that before you can use jquery you will need to include it in your website
$.ajax({
url: '/pages.php?page=dogs
success: function(data) {
$('#content').innerHTML(data);
}
});
Now create a pages.php
<?php
if($_SERVER['REQUEST_METHOD'] == 'GET') {
if (isset($_GET['page'])) {
$page = $_GET['page'];
switch($page)
{
case 'dogs':
echo 'dogs';
break;
case 'cats':
echo 'cats';
break;
default:
echo 'Taka strona nie istnieje';
break;
}
}
}
?>
And don't forget to add the content div in your main page like so
<div id="content"></div>
Upvotes: 1