Learn free online HTML5, javascript, and jquery Tutorials by Examples

Sunday 1 June 2014

How to get the current URL in JavaScript?

-----------------------------------------------
<script src="http://http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
    $(document).ready(function(e) {
        var currentURL = window.location.hostname;
        console.log(currentURL);
    });
</script>


-----------------------------------------------

No comments:

Post a Comment