how to find get url in javascript code code example Example: javascript get current url var currentUrl = window.location.href;