JavaScript: Get anchor from URL जावास्क्रिप्ट: URL से लंगर जाओ
Posted on 10. 10 पर तैनात हैं. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP जून, 2009 Apps, कोडिंग, जावास्क्रिप्ट और Ajax, PHP में Dragos द्वारा
To get the anchor from an URL (this is the text after the # character) in JavaScript you can use the following code: एक URL से लंगर मिल (यह चरित्र # बाद पाठ इस प्रकार है) जावास्क्रिप्ट में आप निम्नलिखित कोड का उपयोग कर सकते हैं:
var url='http://iwebdevel.com/some-post#comment-1'; //if you need to take the current url of the window use: var url=window.location; var url = http://iwebdevel.com/some-post # comment-1 ', / / यदि आप खिड़की के प्रयोग के चालू यूआरएल ले: var url window.location = की जरूरत है; var anchor=url.hash; //anchor with the # character var लंगर url.hash =; / # चरित्र के साथ लंगर / var anchor2=url.hash.substring(1); //anchor without the # character var anchor2 = url.hash.substring (1); # चरित्र के बिना लंगर / /
If you're iterating through the links in a page with JQuery, and $(this) defines a single link, then to find the anchor of this object you'd need to use the following code: यदि आप JQuery के साथ एक पृष्ठ में लिंक के माध्यम से iterating हो, और ($ इस) एक कड़ी को परिभाषित करता है, तो इस उद्देश्य के लंगर आपको निम्न कोड का प्रयोग करना चाहते हैं पता:
var anchor=$(this).attr("hash"); var लंगर = ($ इस attr). ( "हैश"); Related posts: संबंधित पोस्ट:
- Javascript: How to validate email address with JavaScript? : जावास्क्रिप्ट कैसे जावास्क्रिप्ट के साथ ईमेल पते की पुष्टि के लिए?
- JavaScript: How to get the index (position within a group) of an object with jQuery? : जावास्क्रिप्ट कैसे सूचकांक प्राप्त करने की स्थिति एक समूह के भीतर (jQuery के साथ एक वस्तु का)?
- JavaScript: Send function as a parameter to another function (callbacks) जावास्क्रिप्ट: एक और समारोह callbacks (एक पैरामीटर के रूप में कार्य भेजें)
- JavaScript: What if jQuery animation doesn't fire/start? जावास्क्रिप्ट: क्या होगा यदि jQuery एनीमेशन नहीं आग / शुरू कर दिया?
- JavaScript: GIFless animation. जावास्क्रिप्ट: GIFless एनीमेशन. Animate images,logos with jQuery सजीव चित्र, jQuery के साथ लोगो












































