1

I try to enable a brwoserback button for my tabs. But the problem is that in some cases the the hash dissapears.

function showTab1(){ window.location.hash = 'tab1'; oldHash = window.location.hash; //showTab1 } function showTab2(){ window.location.hash = 'tab2'; oldHash = window.location.hash; //showTab2 } function checkBrowserBackButtonInHome(){ setInterval(function(){ if(window.location.hash != oldHash) { //Do something } }, 50); } showTab1(); 

and than I click on showTab2. And when I click on the browser back button the hash dissapears. index.php instead of index.php#tab1

EDIT:

It seems like this only happens in chrome web browser

1 Answer 1

1

try using this instead of the interval:

$(window).bind('hashchange', function() { //Do something }); 
Sign up to request clarification or add additional context in comments.

4 Comments

Can I set in the server side the hashtag I think that is the problem? I'm using PHP
No with PHP you have no access to the hash tag. What you can do is put javascript first thing in your file. window.location.hash = what_you_want. This way it will always be there and mimic being put there with PHP
ok fixed it. I had an anchor with href='index.php' instead it should be href='index.php#tab1'
glad to hear.. you should probably still use the jQuery listener because it will be more efficent.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.