Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to trigger a jquery function just with the url?

this is my first question.. so, here we go.

i have a site, 100% xhtml/css with some ajax functions thanks to jquery.

te problem is.. for all the "sub pages".. the url remains the same (index.php)..

my question is..

does jquery allow some url parameters to trigger an specific function?

example: www.mypage.com -> home page.. if i click on.. let's say products.. the url will be the same.. and if i try to send the url to a friend (copy & paste) it will be www.mypage.com.. so.. if my friend clicks on the link he will be redirected to the home page instead of the products page wich is the section that i want to share with him.

is there anyway to set the url like.. www.mypage.com?s=products to trigger the jquery event without using php?

thanks in advance.

like image 353
Andy Avatar asked Jan 23 '23 15:01

Andy


1 Answers

http://blog.rebeccamurphey.com/2007/12/04/anchor-based-url-navigation-with-jquery/

Never done this, but this site has pretty straight forward method.

Basically you specify an anchor tag for each logical page you have and update the url accordingly when a user navigates to that logical page.

When a new user arrives, you parse the query string (as mentioned above) and then execute the appropriate navigate action.

like image 92
anonymous Avatar answered Jan 29 '23 15:01

anonymous