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"); Related posts: Podobne posty:
- Javascript: How to validate email address with JavaScript? Javascript: Jak potwierdzić adres e-mail z JavaScript?
- 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?
- JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Wyślij funkcji jako parametr do innej funkcji (callback)
- JavaScript: What if jQuery animation doesn't fire/start? JavaScript: Co zrobić, jeśli jQuery animacji nie ognia / start?
- JavaScript: GIFless animation. JavaScript: animacja GIFless. Animate images,logos with jQuery Animowane obrazy, logo z jQuery












































