adding # to the url

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • FrEaKmAn
    New Member
    • Aug 2007
    • 46

    adding # to the url

    Hello

    I might have a weird problem, but I'm seeking for a solution. I have a form with some inputs. I'm using ajax to call a search data and everything works, but problem is when users use back button because it loads the main search page (without results).

    My idea was to store search data or parameters and then recall them when user access the page. As I have

    site.com/browse

    url, I need to know when user is returning and when it just accessed it. So I was thinking to use

    site.com/browse#searchin g

    and by clicking back button, I (site) would know that it's searching. Now how can I add #searching to the url? As I have a form, which also has to work without JS so form (action, mehod) and submit button have to be included. I only know how to add #searching to url with simple link (<a href="#....) but can I add this somehow else?

    EDIT: stupid me, some extra googling and trying solved the problem, simple code as

    window.location .href = "#searching ";

    does the job...
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    location.hash is a better option.

    Comment

    Working...