This is a translated page. The original can be found here: http://iwebdevel.com/2009/06/10/javascript-get-anchor-from-url/
UPDATES VIA RSS | Email עדכונים דרך RSS | אימייל Get updates via feedburner Get updates via twitter
Home / Apps / Coding / JavaScript & Ajax / PHP / JavaScript: Get anchor from … דף הבית / Apps / Coding / JavaScript & אייאקס / PHP / JavaScript: קבל עוגן מ ...

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 ( "חשיש"); 
Translate this post תרגם פירסום


Related posts: הודעות קשורות:

  1. Javascript: How to validate email address with JavaScript? Javascript: כיצד לאמת את כתובת הדוא"ל עם JavaScript?
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: כיצד לקבל את האינדקס (עמדת בתוך קבוצה) של אובייקט עם jQuery?
  3. JavaScript: Send function as a parameter to another function (callbacks) JavaScript: שלח פונקציה כפרמטר לפונקציה אחרת (callbacks)
  4. JavaScript: What if jQuery animation doesn't fire/start? JavaScript: מה אם האנימציה jQuery לא אש / להתחיל?
  5. JavaScript: GIFless animation. JavaScript: אנימציה GIFless. Animate images,logos with jQuery הנפשת תמונות, לוגו עם jQuery

    blog comments powered by Disqus תגובות לבלוג powered by Disqus