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 Aktualizáciou cez RSS | E-mail Get updates via feedburner Get updates via twitter
Home / Apps / Coding / JavaScript & Ajax / PHP / JavaScript: Get anchor from … Home / Apps / Kódovanie / JavaScript & AJAX / PHP / JavaScript: Get kotva od ...

JavaScript: Get anchor from URL JavaScript: Get kotva z URL

Posted on 10. Publikované dňa 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Júna 2009 od Dragos v Apps, Kódovanie, 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: Ak chcete získať kotvu z URL (to je text za znak #), v JavaScriptu, môžete použiť nasledujúci kód:

 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', / / ak chcete mať aktuálne url v okne použitia: var url = window.location;
var anchor=url.hash; //anchor with the # character var anchor = url.hash; / / kotva s # znak
var anchor2=url.hash.substring(1); //anchor without the # character var anchor2 = url.hash.substring (1) / / kotva 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: Ak ste iterácii cez odkazy na stránky s JQuery a $ (this) definuje jeden odkaz, potom nájsť ukotvenie tohto objektu, ktorú by ste mali použiť nasledujúci kód:

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


Related posts: Súvisiace príspevky:

  1. Javascript: How to validate email address with JavaScript? Javascript: Ako overiť e-mailovú adresu JavaScript?
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Ako sa dostať na indexe (pozíciu v rámci skupiny) z objektu s jQuery?
  3. JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Poslať funkcii ako parameter inej funkcie (volanie)
  4. JavaScript: What if jQuery animation doesn't fire/start? JavaScript: Čo keď jQuery animácie nie je oheň / start?
  5. JavaScript: GIFless animation. JavaScript: GIFless animácie. Animate images,logos with jQuery Animovať obrázky, logá s jQuery

    blog comments powered by Disqus blog pripomienky powered by Disqus