I have a code to get number of shares of particular url. The url value is equal to the value we type in a text box.
Part of the code
html
<input type="text" class="form-control" id="urlInput" />
Jquery
$('#getJSON').click(function () {
$('#data-tab').fadeOut();
$URL = $('#urlInput').val();
totalShares($URL);
$('#data-tab').fadeIn();
});
So , here $URL is equal to the value of text box.I need to change it so that $url changes to the value of current address bar url
I am bit new to jquery.I tried searching a lot. I tried replacing it document.url and location.href but it still doesn;t work.
Any tips? thanks
Edit:
I know the terminologies of the code console.log(window.location.href);
,window.location.href.
however, when i use in the code, they don't seem to work
document.URL
orwindow.location.href
.\document.URL
will definitely get you the current URL. If it's not working, the actual URL could be something other than displayed in the browser URL bar. (Similar to how if you try to alert document.URL in a JSFiddle, the url's don't match exactly)