ClickSkills Logo
QUIZZESCOURSESWEBINARSWORKSHOPSCHATBOT
Article

JavaScript मध्ये करंट URL कशी मिळवायची?

Like

Comment

JavaScript मध्ये करंट URL कशी मिळवायची?

जावास्क्रिप्ट मध्ये जी लिंक म्हणजेच URL तुमच्या ऍड्रेस बार मध्ये दिसत आहे ती कशी मिळवायची हे आपण या आर्टिकल मध्ये बघणार आहोत.

तर मुळात याचा कोड फारच सोपा आहे. अगदीच २ ओळींचा हा कोड आहे.

function getCurrentURL () { return window.location.href } const url = getCurrentURL()

फक्त एवढाच कोड जर तुम्ही रन केलात तर तुम्हाला ब्राउजर मध्ये असलेला URL तुमच्या अप्लिकेशन मध्ये वापरता येईल.

ES६ मध्ये तुम्हाला माहित आहे कि ऑब्जेक्ट तुम्हाला डीस्ट्रक्चर करता येतो. तर जो window.location.href हा ऑब्जेक्ट आहे याच्या प्रॉपर्टी पण आपण डीस्ट्रक्चर करू शकतो.

const { host, hostname, href, origin, pathname, port, protocol, search } = window.location

मग जर आपण आता ज्या url वर आहे त्याचा अभ्यास केला तर वरील गोष्टी काय काय येतील?

https://clickskills.in/mr/blog/posts/get-current-url-in-javascript-in-marathi //host: clickskills.in //hostname: clickskills //href: https://clickskills.in/mr/blog/posts/get-current-url-in-javascript-in-marathi //origin: https://clickskills.in //pathname: /mr/blog/posts/get-current-url-in-javascript-in-marathi //port: "" //protocol: https: //search: ""

तर अशा पद्धतीने आपण जावास्क्रिप्ट मधील URL चे वेगवेगळे भाग वापरू शकतो.

Comments

0

No comments yet

Be the first to share your thoughts on this article

About the Author

P

Prathamesh Sakhadeo

Expert content creator and educator at ClickSkills, passionate about sharing knowledge and helping learners achieve their goals.

Article Info

Read Time

1 min read

Views

41

Likes

0

Published

Oct 14, 2025

Share this Article

Quick Actions

Browse All ArticlesExplore Courses

Resources

For TutorsFor StudentsBlogInstructors

Associations

AIC RMP
Startup India
SciTech

Subscribe

Email us: support@clickskills.in

Call us: 9 00 11 55 44 6

© 2026 ClickSkills EdTech Pvt Ltd


Disclaimer: All trademarks, logos, and brand names used on this website belong to their respective owners. We do not claim any ownership or affiliation unless stated otherwise.