new URL get full url js code example Example 1: get actual url in variable var currentLocation = window.location; Example 2: current url window.location.href