window.location - javascript fetching and a variable from the url -
i have following url
http://www.domain.co.uk/example/#project-471-1747
the end bit #project-471-1747 changes every time project saved.
i pretty sure using window.location can pulled struggling find out how pull , display full url when button clicked.
i'm sure must pretty simple seems eluding me!
your button markup can this:
<input type="button" value="display url" onclick="urldisplay()">
what is, on click of button, calls function called urldisplay()
. can have in function show full url:
console.log(window.location.hostname + window.location.pathname);
of course, might not want use console.log. can choose append part of markup.
Comments
Post a Comment