Jump to content

Hash URL based website. load pages with multiple variables in url. etc.


Recommended Posts

I have a website that is completely hash based. It only ever loads one page the whole time you're on the site. The rest of the pages are loading in with ajax. What I am using to check for hash changes is

$(window).hashchange( function (){});

and everytime the hash changes it loads the page that it tells it to based on whats in the hash. Now. This works perfectly fine when i just have one variable in the url that needs to load the page, however when i want to have a tabbed navigation inside of the first page that loads it either has to load the entire page again. (which would make this completely pointless if I kept it like this), or i cannot pass a url in the hash, (which wouldn't work because if you reload the page it wouldn't automatically go back to that tab and everything. So what I need is a better system in how i get pages through the hash.

 

Okay to make it more clear as to what I am looking for I'll show some examples.

 

example hash with only one page needing to be loaded.

www.mysite.com/index.php#!/profile&id=1

 

This will load the php page called profile.php, with the users ID as number 1.

 

now, when you click on a tab on the users page the url would look something like this:

www.mysite.com/index.php#!/profile&id=1&tab=information

 

This will load information.php into a div inside of the profile.php page without reloading the profile page. (Well I mean that's what i want it to do)

 

Could anyone give me some direction in how I could accomplish this. Thanks a lot.

I'm not 100% sure if I understand your problem, but if I'm understanding it right, you can create a global for the current page, and a global for the current tab, and then check to see if the page or tab in the hash are different from the ones in the global. If they are, load the relevant page or tab, then store the new page or tab in the variable.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.