- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 jQuery?
For getting the current URL you can use attr() method or window.location.
Example
<html> <head> <title>url</title> <script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { $("button").click(function () { alert($(location).attr('href')); alert(window.location); }); }); </script> </head> <body> <div> <button type="button" id="btn">Display URL</button> </div> </body> </html>
- Related Articles
- How to get current URL in JavaScript?
- How to get the current URL with JavaScript?
- How to get the Current URL inside the @if Statement in Laravel?
- How to get an object containing parameters of current URL in JavaScript?
- How do I get current URL in Selenium Webdriver 2 Python?
- How to get image data url in JavaScript?
- Firebase to get url
- How to get a bitmap from Url in Android app?
- How to get parameters from a URL string in PHP?
- How to get an attribute value in jQuery?
- How to put url into a variable when button is clicked - jQuery?
- How to get the current year in JavaScript?
- How to get current activity name in android?
- How to get current Bluetooth address in android?
- How to get current Bluetooth name in android?

Advertisements