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

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -