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 Updates via RSS | Email Get updates via feedburner Get updates via twitter
Home / Apps / Coding / JavaScript & Ajax / PHP / JavaScript: Get anchor from … Home / Apps / kodim / Javascript dhe AJAX / PHP / Javascript: Merrni të ankorohen nga ...

JavaScript: Get anchor from URL JavaScript: Merrni të ankorohen nga URL

Posted on 10. Dërguar të 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Qershor, 2009 nga DragosApps, kodim, 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: Për të marrë të ankorohen nga një URL (ky është tekst pas karakter #) në të aktivizoni Java ju mund të përdorni kodin e mëposhtëm:

 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 koment http://iwebdevel.com/some-post = '# 1'; / / në qoftë se keni nevojë për të marrë url aktual i përdorimit dritare: var url window.location =;
var anchor=url.hash; //anchor with the # character spirancë var = url.hash; / / spirancë me karakter #
var anchor2=url.hash.substring(1); //anchor without the # character var anchor2 = url.hash.substring (1); / / ankorohen pa karakter # 

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: Nëse ju jeni iterating përmes lidhjeve në një faqe me jQuery, dhe $ (kjo) përcakton një lidhje të vetme, atëherë për të gjetur të ankorohen të këtij objekti do të keni nevojë të përdorni kodin e mëposhtëm:

 var anchor=$(this).attr("hash"); spirancë var = $ (këtë). attr ( "hash"); 
Translate this post Translate this post


Related posts: Related posts:

  1. Javascript: How to validate email address with JavaScript? Javascript: Si të vërtetoni adresën e email me të aktivizoni Java?
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? Java: Si të merrni indeksi (pozitë brenda një grupi) e një objekti me jQuery?
  3. JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Send të funksionojë si një parametër të një tjetër funksion (callbacks)
  4. JavaScript: What if jQuery animation doesn't fire/start? Java: Çfarë ndodh nëse animacion jQuery nuk zjarr / filloni?
  5. JavaScript: GIFless animation. JavaScript: animacion GIFless. Animate images,logos with jQuery Imazhe gjallë, logot me jQuery

    blog comments powered by Disqus Komentet blog powered by Disqus