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 Atualizações Via RSS | Email Get updates via feedburner Get updates via twitter
Home / Apps / Coding / JavaScript & Ajax / PHP / JavaScript: Get anchor from … Home / Aplicativos / Codificação / JavaScript e Ajax / PHP / JavaScript: Get âncora da ...

JavaScript: Get anchor from URL JavaScript: Get âncora de URL

Posted on 10. Postado em 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Junho de 2009 por Dragos em 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 âncora de uma URL (este é o texto após o caractere #) no Javascript você pode usar 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 você precisa de ter o URL actual da utilização da janela: var url = window.location;
var anchor=url.hash; //anchor with the # character var anchor = url.hash; / âncora / com o caractere #
var anchor2=url.hash.substring(1); //anchor without the # character var anchor2 url.hash.substring = (1); / âncora / sem o caractere # 

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 você está interagindo com os links em uma página com JQuery, e US $ (este), define uma única ligação, em seguida, para encontrar a âncora desse objeto que você precisa usar o seguinte código:

 var anchor=$(this).attr("hash"); var anchor = $ (this) attr. (hash "); 
Translate this post Traduzir este post


Related posts: Related posts:

  1. Javascript: How to validate email address with JavaScript? Javascript: Como validar endereço de e-mail com JavaScript?
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Como obter o índice (posição dentro de um grupo) de um objeto com jQuery?
  3. JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Enviar funcionar como um parâmetro para outra função (callbacks)
  4. JavaScript: What if jQuery animation doesn't fire/start? JavaScript: E se a animação jQuery não activado / começar?
  5. JavaScript: GIFless animation. JavaScript: animação GIFless. Animate images,logos with jQuery Anime imagens, logotipos com jQuery

    blog comments powered by Disqus blog comentários powered by Disqus