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"); Related posts: Related posts:
- Javascript: How to validate email address with JavaScript? Javascript: Come validare indirizzo email con JavaScript?
- 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?
- JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Invia funzione come parametro a un'altra funzione (callback)
- JavaScript: What if jQuery animation doesn't fire/start? JavaScript: jQuery Che cosa succede se l'animazione non viene generato / start?
- JavaScript: GIFless animation. JavaScript: animazione GIFless. Animate images,logos with jQuery Animare le immagini, i loghi con jQuery












































