Reputation: 443
I just got started with PHP to build my website. Everything was fine, untile I tried to use my navbar. This is what it looks like:
This is navbar.php
which gets included into index.php
.
<div class="nav-items">
<ul>
<li><a href="biography.php">Biography</a></li>
<li><a href="music.php">Music</a></li>
<li><a href="pictures.php">Pictures</a></li>
<li><a href="concerts.php">Concerts</a></li>
<li><a href="booking.php">Booking</a></li>
</ul>
</div>
When I click a link in my navbar, it doesn't direct me to the page. It's the same behavior as when you'd write href="#"
. I just stay on the page, the URL doesn't change.
When I hover over the links, the path I see is correct. And when I manually type in that path, it works perfectly, the page gets rendered.
My file structure:
navbar.php
footer.php
index.php
biography.php
music.php
pictures.php
concerts.php
booking.php
I'm using XAMPP to run the site locally. Can anyone see what I'm doing wrong here?
EDIT:
Thanks to @syck I've now found out that a part of my jQuery code was responsible. It was code I used to display the active page:
$(function() {
$('.navbar').on('click', 'div.nav-items ul li a', function(e) {
e.preventDefault();
$(this).parents('.navbar').find('.active').removeClass('active').end().end().addClass('active');
$(activeTab).show();
});
});
Once this code is removed, navigation works like a charm. Anyone know why it would cause this behavior?
Upvotes: 2
Views: 9220
Reputation: 9
i think there is some error with the path u have given.. give the correct path. check whether biography.php is found in the same location where the index.php is found.
Upvotes: 0
Reputation: 540
Add
<base href="your website" >element in index.php
Upvotes: 0
Reputation: 686
<div class="nav-items">
<ul>
<li><a href="../biography.php">Biography</a></li>
<li><a href="../music.php">Music</a></li>
<li><a href="../pictures.php">Pictures</a></li>
<li><a href="../concerts.php">Concerts</a></li>
<li><a href="../booking.php">Booking</a></li>
</ul>
</div>
i hope this will work
Upvotes: 2
Reputation: 14169
Try this way
<div class="nav-items">
<ul>
<li><a href="../biography.php">Biography</a></li>
<li><a href="../music.php">Music</a></li>
<li><a href="../pictures.php">Pictures</a></li>
<li><a href="../concerts.php">Concerts</a></li>
<li><a href="../booking.php">Booking</a></li>
</ul>
</div>
Upvotes: 0