Skip to content

Instantly share code, notes, and snippets.

@kovaldn
Last active March 17, 2016 14:18
Show Gist options
  • Save kovaldn/5283672 to your computer and use it in GitHub Desktop.
Save kovaldn/5283672 to your computer and use it in GitHub Desktop.
Javascript: window location
/*
* ---------------------
* WINDOW LOCATION
* ---------------------
* http://javascript.ru/window-location
*/
http://www.google.com:80/search?q=javascript#test
window.location.hash // '#test'
window.location.href // 'http://www.google.com:80/search?q=javascript#test'
window.location.hostname // 'www.google.com'
window.location.pathname // '/search'
window.location.search // '?q=javascript'
window.location.assign(url) // загрузить документ по данному url
window.location.replace(url) // заменить текущий документ на документ по указанному url
window.location.reload([forceget]) // перезагрузить документ. Аргумент forceget - булево значение, если оно true, то документ перезагружается всегда с сервера, если false или не указано, то браузер может взять страницу из своего кэша.
window.location.toString() // строковое представление URL
// примеры
window.location = "http://javascript.ru"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment