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 Actualizări prin RSS | E-mail Get updates via feedburner Get updates via twitter
Home / Apps / Coding / JavaScript & Ajax / PHP / JavaScript: Get anchor from … Prima / Apps / codificare a mărfurilor / JavaScript & Ajax / PHP / JavaScript: da ancora de la ...

JavaScript: Get anchor from URL JavaScript: Ia ancora de la URL-ul

Posted on 10. Postat la data de 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Iunie, 2009 de către Dragos în Apps, codificare a mărfurilor, 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: Pentru a obţine o ancoră de la URL-ul (acesta este textul de după caracterul #) în JavaScript puteţi folosi următorul cod:

 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'; / / Dacă aveţi nevoie de a lua URL-ul actual de utilizare fereastra: var url = window.location;
var anchor=url.hash; //anchor with the # character ancora var = url.hash; / / Anchor cu caracterul #
var anchor2=url.hash.substring(1); //anchor without the # character var anchor2 = url.hash.substring (1); / / Anchor fără caracter # 

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: Dacă sunteţi iterarea prin link-uri într-o pagină cu jQuery, şi $ (aceasta), defineşte un singur link, apoi să găsească ancora a acestui obiect aveţi nevoie pentru a folosi următorul cod:

 var anchor=$(this).attr("hash"); ancora var = $ (aceasta). attr ( "hash"); 
Translate this post Traduceţi acest post


Related posts: Legate de posturi:

  1. Javascript: How to validate email address with JavaScript? Javascript: Cum, pentru a valida adresa de e-mail cu JavaScript?
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Cum se ajunge indicele (poziţia în cadrul unui grup), de un obiect cu jQuery?
  3. JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Trimite funcţioneze ca un parametru de la o altă funcţie (Callbacks)
  4. JavaScript: What if jQuery animation doesn't fire/start? JavaScript: Ce se întâmplă dacă animaţie jQuery nu de incendiu / începe?
  5. JavaScript: GIFless animation. JavaScript: animaţie GIFless. Animate images,logos with jQuery Animate imagini, logo-urile cu jQuery

    blog comments powered by Disqus comentarii blog-ul creat de Disqus