Reputation: 137
I had to rename all of my .html files to .php so that I can use php gzip compression. Anyway the switch has broken one of my scripts. It's a script that loads in and animates content. It grabs the content from various pages and loads it into a container. That part of the script works fine.
When using the .html extension, the script will happily append the page being viewed to the URL, as in: www.site.com/#ABOUT
But now that I've renamed everything from .html to .php, there's always a missing letter, as in: www.site.com/#ABOU <--- missing a 'T'
Or, www.site.com/#CONTAC <--- missing a 'T'
www.site.com/#NEWSLETTE <--- missing an 'R'
Here's the part of the script that does this append function:
var hash = window.location.hash.substr(1);
var href = $('#nav li a').each(function(){
var href = $(this).attr('href');
if(hash==href.substr(0,href.length-5)){
var toLoad = hash+'.php #content'; <--- .php (was: .html)
$('#content').load(toLoad)
}
});
What's up with this?
Upvotes: 0
Views: 81
Reputation: 664650
If href.substr(0,href.length-5)
was intended to remove .html
, you might need to change it to href.substr(0,href.length-4)
so it removes .php
.
Upvotes: 0
Reputation: 9132
I'm not going to say this is the right way to do it, but changing this should work:
if(hash==href.substr(0,href.length-4)){
var toLoad = hash+'.php #content'; <--- .php (was: .html)
$('#content').load(toLoad)
}
Upvotes: 1
Reputation: 14573
href.substr(0,href.length-5)
Since your switch from .html to .php, you want
href.substr(0,href.length-4)
Upvotes: 3