I am working with JavaScript and AJAX. One of the AJAX function adds the “#” sign at the end of the URL. The function works, but I want to know why only this function adds that sign and not the other functions. Could the “#” sign bring some problems on the future?
Share
a
#sign on a URL is called the hash sign and tend to separate the URL from the anchor on the page, so you can navigate to portions of the page and not only to the top of the page.In the AJAX world, this can be also used to keep the current page and you can easily know where you came from (as pages are loaded async) so you can easily go back without using the
historyapi (alpha version of jQueryMobile used this technique)in a url like
http://domain.com/page2.htm#page1.htmyou can easily know where do you came from usingdocument.location.hashbut normally is simple having an anchor tag with the hash as
hreflike<a href="#">click here</a>witch normaly is a simple trick to let theanchortag know to behave like a link but go nowhere … and if you don’t want that to be written in your URL, you simply have to returnfalseso the anchor link do not jump to#(witch is the current page).BTW, this will not, in any way, mess up with your code or any future code, it’s just bad practice.