Mam następujący kod w widoku MVC3:window.location.hash zwraca hash tag przed wartością
$(document).ready(function() {
if (window.location.hash) {
var manager= new Manager();
manager.doSomeStuff(window.location.hash);
}
});
Interesującą rzeczą jest to, że gdy nie ma hash tag w adresie URL, lub istnieje tylko przykładem hash tag:
http://localhost:1223/Index/AboutUs
http://localhost:1223/Index/AboutUs#
Gdy window.location.hash
jest pusta, a funkcja nie jest wykonywany. Ale kiedy jest jakaś wartość w tagu hash:
http://localhost:1223/Index/AboutUs#categoryId=5&manufacturerId=8
Wartość w window.location.hash
jest #categoryId=5&manufacturerId=8
Czy możesz mi wyjaśnić, dlaczego tag #
jest wliczone w wartość i dlatego, kiedy tam nie ma wartość po tagu #
, window.location.hash
jest pusta.
Tak, to robi ??? – adeneo