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 AĠĠORNAMENTI VIA RSS | Email Get updates via feedburner Get updates via twitter
Home / Apps / Coding / JavaScript & Ajax / PHP / JavaScript: Get anchor from … Home / apps / Kodifika / javascript & Ajax / PHP / javascript: Niżżel l-ankra minn ...

JavaScript: Get anchor from URL JavaScript: Get ankra mill-URL

Posted on 10. Posted on 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Ġunju, 2009 minn Dragos fl apps, Kodifika, 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: Biex tikseb l-ankra minn URL (dan huwa t-test wara l-karattru #) fl JavaScript tista 'tuża l-kodiċi li ġejjin:

 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; url var = "http://iwebdevel.com/some-post # comment-1"; / / jekk ikollok bżonn tieħu l-url attwali ta 'l-użu tieqa: var url = window.location; 
 var anchor=url.hash; //anchor with the # character ankra var = url.hash; / / ankra mal-karattru # 
 var anchor2=url.hash.substring(1); //anchor without the # character var anchor2 = url.hash.substring (1); / / ankra mingħajr il-karattru # 

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: Jekk int mtennija permezz tar-rabtiet fil-paġna ma JQuery, u $ (dan) jiddefinixxi rabta waħda, allura biex issib l-ankra ta 'dan l-oġġett inti'd bżonn li jintuża l-kodiċi li ġej:

 var anchor=$(this).attr("hash"); ankra var = $ (dan). attr ( "hash"); 
Translate this post Ittraduċi din il-kariga


Related posts: Related postijiet:

  1. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Kif tista 'tikseb l-indiċi (il-pożizzjoni fi ħdan grupp) ta' oġġett jQuery?
  2. Javascript: How to validate email address with JavaScript? Javascript: Kif biex jivvalida l-indirizz email bl JavaScript?
  3. JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Send funzjoni bħala parametru ieħor għall-funzjoni (callbacks)
  4. JavaScript: What if jQuery animation doesn't fire/start? JavaScript: X'jiġri jekk jQuery animazzjoni ma 'nar / tibda?
  5. JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Fejn nista Find All Properties for All Elementi HTML?

    blog comments powered by Disqus blog kummenti powered by Disqus