javscript url path code example Example 1: javascript get url path window.location.pathname Example 2: javascript get domain window.location.hostname