EDITABLE CODE:
LiveDemo: JavaScript Demo
Note:location object grants access to the currently loaded URI(Uniform Resource Identifier) and its properties.