Reputation: 83
In my header I have the following script to receive an id parameter input to the function recp() :
<script>
function take(id) {
$('#content_div').load('pages.php?id='+id);
}
</script>
In my navigation menu in the body, I have my links set as follows:
<li><a href="#" onClick="take('food')">Food</a></li>
<li><a href="#" onClick="take('animals')">Animals</a></li>
My div tag is like this in the body:
<div id="content_div"><div>
pages.php has a conditional structure to inject specific code into the #content_div as follows:
<?php
$id = $_GET['id'];
function showUp($id){
switch($id){
case "food":
include_once "food.php";
break;
case "animals":
include_once'animals.php';
break;
}
?>
The content is loading perfectly but I have issues with the URL. How can I achieve to use the back button and navigate to the previously opened state such that they can be bookmarked?
Upvotes: 2
Views: 400
Reputation: 1508
You should to push browser history state programmatically in your case. History.js – handling this issue. Here you can take code and manual: https://github.com/browserstate/history.js
Upvotes: 1