JavaScript: Get anchor from URL JavaScript: קבל עוגן מתוך כתובת
Posted on 10. פורסם ב 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP יוני, 2009 על ידי Dragos ב Apps, Coding, JavaScript & Ajax, PHP
To get the anchor from an URL (this is the text after the # character) in JavaScript you can use the following code: כדי לקבל את העוגן מן כתובת אתר (זה טקסט לאחר התו #) ב-JavaScript ניתן להשתמש את הקוד הבא:
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: אם אתה iterating דרך הקישורים בדף עם jQuery, ו $ (זה) מגדירה קישור יחיד, ואז למצוא את העוגן של אובייקט זה היית צריך להשתמש בקוד הבא:
var anchor=$(this).attr("hash"); עוגן var = $ (זה). attr ( "חשיש"); Related posts: הודעות קשורות:
- Javascript: How to validate email address with JavaScript? Javascript: כיצד לאמת את כתובת הדוא"ל עם JavaScript?
- JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: כיצד לקבל את האינדקס (עמדת בתוך קבוצה) של אובייקט עם jQuery?
- JavaScript: Send function as a parameter to another function (callbacks) JavaScript: שלח פונקציה כפרמטר לפונקציה אחרת (callbacks)
- JavaScript: What if jQuery animation doesn't fire/start? JavaScript: מה אם האנימציה jQuery לא אש / להתחיל?
- JavaScript: GIFless animation. JavaScript: אנימציה GIFless. Animate images,logos with jQuery הנפשת תמונות, לוגו עם jQuery












































