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