Javascript environment demo

JS can detect various things on the client side.
  

location

JS Value Notes
location (complex object) location
Type "location" into Console to explore it
location.href location.href
  

document

JS Value Notes
document (complex object) document
Type "console.dir(document)" into Console to explore it
document.referrer document.referrer
document.characterSet document.characterSet
document.lastModified document.lastModified
Requires server to send Last-Modified HTTP header. Look in HTTP headers for this page (how?) and you will see our server does not send this info.
  

navigator

JS Value Notes
navigator (complex object) navigator
Type "navigator" into Console to explore it
navigator.userAgent navigator.userAgent
navigator.appVersion navigator.appVersion
navigator.platform navigator.platform
navigator.geolocation (JS cannot read values for location without asking user.)

navigator.geolocation
The function getCurrentPosition() is used to ask user if we can get location.
Can ask automatically on page load (common) or on button click (as here).