get actual url in variable
var currentLocation = window.location;
get actual url in variable
var currentLocation = window.location;
javascript get domain
window.location.hostname
url in js
window.location.protocol = “http:”
window.location.host = “css-tricks.com”
window.location.pathname = “/example/index.html”
window.location.search = “?s=flexbox”const
postID = (new URLSearchParams(window.location.search)).get('post');
javascript hashtag url
var hash = window.location.hash;
if (hash) {
// Fragment exists
hash = hash.substring(1);
console.log(hash);
} else {
// Fragment doesn't exist
}
javascript url
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript</h2>
<h3>The window.location object</h3>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
"The full URL of this page is:<br>" + window.location.href;
</script>
</body>
</html>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us