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 Aktualizacje pocztą RSS | Email Get updates via feedburner Get updates via twitter
Home / Apps / Coding / JavaScript & Ajax / PHP / JavaScript: Get anchor from … Home / Aplikacje / Coding / JavaScript i Ajax / PHP / JavaScript: Get kotwica od ...

JavaScript: Get anchor from URL JavaScript: Get kotwicę z adresu URL

Posted on 10. Zamieszczone w dniu 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Cze, 2009 Dragos w Aplikacje, Coding, JavaScript i Ajax, PHP

To get the anchor from an URL (this is the text after the # character) in JavaScript you can use the following code: Aby uzyskać kotwicę z adresu URL (jest to tekst po znaku #) w JavaScript można użyć następującego kodu:

 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" / / jeśli chcesz mieć aktualny adres URL wykorzystania okno: var url = window.location;
var anchor=url.hash; //anchor with the # character var anchor = url.hash / / kotwica się od znaku #
var anchor2=url.hash.substring(1); //anchor without the # character var anchor2 = url.hash.substring (1) / / kotwica bez znaku # 

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: Jeśli jesteś iterację poprzez linki na stronie z jQuery i $ (this) definiuje jeden link, a następnie znaleźć kotwica tego obiektu, którą należy użyć następującego kodu:

 var anchor=$(this).attr("hash"); var anchor = $ (this). attr ( "hash"); 
Translate this post Translate this post


Related posts: Podobne posty:

  1. Javascript: How to validate email address with JavaScript? Javascript: Jak potwierdzić adres e-mail z JavaScript?
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Jak zdobyć indeks (pozycja w grupie) obiektu z jQuery?
  3. JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Wyślij funkcji jako parametr do innej funkcji (callback)
  4. JavaScript: What if jQuery animation doesn't fire/start? JavaScript: Co zrobić, jeśli jQuery animacji nie ognia / start?
  5. JavaScript: GIFless animation. JavaScript: animacja GIFless. Animate images,logos with jQuery Animowane obrazy, logo z jQuery

    blog comments powered by Disqus blog komentarze powered by Disqus