Does anyone know how to get url and title of the current page by using Javascript without jQuery!?
<script type="text/javascript">
var title = document.getElementsByTagName('title')[0].innerHTML;
var url = document.location.href
socializ(encodeURIComponent('+href+'),encodeURIComponent('+title+'))
</script>
Just doesn't work.. need help...
The location
object is what you're after for the URL piece:
var currentURL = window.location.href;
And for the title, document.title
:
var title = document.title;
window.location.href
for the URL and document.title
for the title.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With