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 Aggiornamenti via RSS | Email Get updates via feedburner Get updates via twitter
Home / Apps / Coding / JavaScript & Ajax / PHP / JavaScript: Get anchor from … Home / Apps / Coding / JavaScript e Ajax / PHP / JavaScript: Get ancora da ...

JavaScript: Get anchor from URL JavaScript: Get ancora da URL

Posted on 10. Posted on 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Giugno, 2009 da Dragos in Apps, codificazione, JavaScript e Ajax, PHP

To get the anchor from an URL (this is the text after the # character) in JavaScript you can use the following code: Per ottenere l'ancoraggio da un URL (questo è il testo dopo il carattere #) in JavaScript è possibile utilizzare il seguente codice:

 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'; / / se avete bisogno di prendere l'URL corrente della finestra di utilizzo: var url = window.location; 
 var anchor=url.hash; //anchor with the # character var anchor = url.hash; / / ancoraggio con il carattere # 
 var anchor2=url.hash.substring(1); //anchor without the # character var anchor2 = url.hash.substring (1); / / anchor senza il carattere # 

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: Se stai scorrendo i link in una pagina con jQuery, e $ (questo), definisce un singolo collegamento, quindi per trovare l'ancoraggio di questo oggetto avresti bisogno di utilizzare il seguente codice:

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


Related posts: Related posts:

  1. Javascript: How to validate email address with JavaScript? Javascript: Come validare indirizzo email con JavaScript?
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Come ottenere l'indice (posizione all'interno di un gruppo) di un oggetto con jQuery?
  3. JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Invia funzione come parametro a un'altra funzione (callback)
  4. JavaScript: What if jQuery animation doesn't fire/start? JavaScript: jQuery Che cosa succede se l'animazione non viene generato / start?
  5. JavaScript: GIFless animation. JavaScript: animazione GIFless. Animate images,logos with jQuery Animare le immagini, i loghi con jQuery

    blog comments powered by Disqus commenti del blog powered by Disqus