JavaScript: Get anchor from URL JavaScript: Get Referencia de URL
Posted on 10. Posta en 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Xuño de 2009 por Dragos en Apps, Coding, 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: Para obter o destino dunha URL (este é o texto despois do carácter #) o Javascript pode utilizar o seguinte código:
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 precisa ter a dirección actual do uso da ventá: var url = window.location; var anchor=url.hash; //anchor with the # character var Anchor = url.hash; / Referencia / co carácter # var anchor2=url.hash.substring(1); //anchor without the # character var anchor2 url.hash.substring = (1); / Referencia / sen o carácter #
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 está a interactuar con as ligazóns dunha páxina con JQuery, e US $ (este), define unha única conexión, desde logo, para atopar a áncora dese obxecto que cómpre usar o seguinte código:
var anchor=$(this).attr("hash"); var Anchor = $ (this) attr. (hash "); Related posts: Related posts:
- Javascript: How to validate email address with JavaScript? Javascript: Como validar enderezo de correo-e JavaScript?
- JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Como obter o índice (posición dentro dun grupo) dun obxecto con jQuery?
- JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Enviar funcionar como un parámetro para outra función (callbacks)
- JavaScript: What if jQuery animation doesn't fire/start? JavaScript: E se a animación jQuery non activar / comezar?
- JavaScript: GIFless animation. JavaScript: animación GIFless. Animate images,logos with jQuery Ánimo fotos, logotipos con jQuery












































