Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get current URL in JavaScript?
The window.location object can be used to get the current URL.
window.location.href returns the href(URL) of the current page.
I am using these code in my MVC projet.
Example
<html>
<body>
<div>
<p id ="dd"></p>
</div>
<script type="text/javascript">
var iid=document.getElementById("dd");
alert(window.location.href);
iid.innerHTML = "URL is" + window.location.href;
</script>
</body>
</html>Advertisements