Today, We want to share with you Simple JavaScript Retrieve current url Example.In this post we will show you How to get Full Request URL or Route in javascript, hear for javascript Retrieve Current URL with Parameters we will give you demo and example for implement.In this post, we will learn about How to get current url with or without query string example jQuery with an example.
Simple JavaScript Get current url Example
There are the Following The simple About How to Retrieve Full URL with parameters in JavaScript? Full Information With Example and source code.
As I will cover this Post with live Working example to develop jquery Retrieve Full url with parameters, so the how to send query string in jquery is used for this example is following below.
JavaScript Retrieve current url
More About Full Url In JavaScript
<script type="text/javascript"> var currentURL = window.location.href; </script>
JavaScript Retrieve current url parameters
<script type="text/javascript"> function retriveCurrentURL(arg) { var sqay = window.location.search.substring(1); var datas = sqay.split("&"); for (var i=0;i<datas.length;i++) { var uri = datas[i].split("="); if (uri[0] == arg) { return uri[1]; } } alert("currentURL Parameter not found."); } // suppose url is www.your_domain_name.com?&q1=movile&q2=deepakbhaodiya; var currentURL = retriveCurrentURL(q1); alert(currentURL);// will give you movile </script>
Javascript Full url protocal name
<script type="text/javascript"> function retriveCurrentURL(){ var currentURL_protocol = location.protocal; alert(currentURL_protocol);// example http:: or https } </script>
Javascript Current url hostname
<script type="text/javascript"> function retriveCurrentURL(){ var currentURL_host = location.hostname; alert(currentURL_host);// such as - your_domain_name.com } </script>
JavaScript Retrieve current url without parameters
<script type="text/javascript"> function getCurrentUrl(){ var currentURL_protocol_host = location.protocol + '//' + location.host; alert(currentURL_protocol_host);// example - www.your_domain_name.com } </script>
JavaScript Retrieve query strings from url
<script type="text/javascript"> function retriveCurrentURL(){ var currentURL = location.pathname; alert(currentURL);// } </script>
Web Programming Tutorials Example with Demo
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about javascript Retrieve url parameter.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.
I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I’m a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.