Babban matsalar ita ce "URL na yanzu" a cikin JavaScript ba koyaushe abin dogaro bane. Misali, idan ka loda shafi a cikin mai binciken gidan yanar gizo, URL na yanzu zai zama adireshin shafin da kansa. Idan ka loda shafin ta amfani da wani mashigin bincike daban, ko kuma idan ka loda shi daga fayil akan kwamfutarka, URL ษin na yanzu na iya bambanta.
var currentURL = window.location.href;
Wannan layin lambar yana bayyana maษalli da ake kira "currentURL" kuma ya sanya masa ฦimar URL ษin shafin yanar gizon yanzu.
samu halin yanzu Properties
Akwai ฦดan hanyoyi don samun abubuwan mallakar abu na yanzu a JavaScript. Hanya ษaya ita ce amfani da hanyar Object.getOwnPropertyNames(). Wannan hanyar tana dawo da jerin duk abubuwan mallakar abu. Hakanan zaka iya amfani da sunan kadarorin azaman mai canzawa don samun damar ฦimar kadarorin.
Wata hanya don samun abubuwan da ke cikin abu na yanzu shine amfani da hanyar Object.keys(). Wannan hanyar tana dawo da jerin duk maษallan (ko masu ganowa na musamman) na wani abu. Hakanan zaka iya amfani da sunan maษalli azaman mai canzawa don samun damar ฦimar da ke da alaฦa da wannan maษalli.