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 Aktualizací přes RSS | E-mail Get updates via feedburner Get updates via twitter
Home / Apps / Coding / JavaScript & Ajax / PHP / JavaScript: Get anchor from … Home / Apps / Kódování / JavaScript & AJAX / PHP / JavaScript: Get kotva od ...

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

Posted on 10. Publikováno dne 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Června 2009 od Dragos v Apps, Kódování, 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: Chcete-li získat kotvu z URL (to je text za znak #), v JavaScriptu, můžete použít následující 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', / / pokud chcete mít aktuální url v okně použití: 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: Pokud jste iteraci přes odkazy na stránky s JQuery a $ (this) definuje jeden odkaz, pak najít ukotvení tohoto objektu, kterou byste meli použít následující kód:

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


Related posts: Související příspěvky:

  1. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Jak se dostat na indexu (pozici v rámci skupiny) z objektu s jQuery?
  2. Javascript: How to validate email address with JavaScript? Javascript: Jak ověřit e-mailovou adresu JavaScript?
  3. JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Poslat funkci jako parametr jiné funkce (volání)
  4. JavaScript: What if jQuery animation doesn't fire/start? JavaScript: Co když jQuery animace není oheň / start?
  5. JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Kde najdu všechny vlastnosti pro všechny prvky HTML?

    blog comments powered by Disqus blog připomínky powered by Disqus