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 MISES A JOUR VIA RSS | Email Get updates via feedburner Get updates via twitter
Home / Apps / Coding / JavaScript & Ajax / PHP / JavaScript: Get anchor from … Accueil / Applications / Codage / JavaScript et Ajax / PHP / JavaScript: Get ancrage à partir du ...

JavaScript: Get anchor from URL JavaScript: Obtenir l'ancre dans l'url

Posted on 10. Posté le 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Jun, 2009 par Dragos dans Apps, codage, JavaScript et Ajax, PHP

To get the anchor from an URL (this is the text after the # character) in JavaScript you can use the following code: Pour obtenir le point d'ancrage à partir d'une URL (il s'agit du texte après le caractère #) en JavaScript vous pouvez utiliser le code suivant:

 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; http://iwebdevel.com/some-post var url = '# comment-1'; / / si vous avez besoin de prendre l'URL actuelle de l'utilisation fenêtre: var window.location = url;
var anchor=url.hash; //anchor with the # character ancre var = url.hash; / / ancre avec le caractère #
var anchor2=url.hash.substring(1); //anchor without the # character var anchor2 = url.hash.substring (1); / / ancre sans le caractère # 

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: Si nous parcourons les liens dans une page avec jQuery, $ (this) définit un lien unique, puis de trouver le point d'ancrage de cet objet vous aurez besoin d'utiliser le code suivant:

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


Related posts: Related posts:

  1. Javascript: How to validate email address with JavaScript? Javascript: Comment faire pour valider l'adresse e-mail avec JavaScript?
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Comment obtenir l'index (la position dans un groupe) d'un objet avec jQuery?
  3. JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Envoyer fonction comme paramètre à une autre fonction (rappels)
  4. JavaScript: What if jQuery animation doesn't fire/start? JavaScript: Que faire si jQuery animation ne se déclenche pas / start?
  5. JavaScript: GIFless animation. JavaScript: GIFless animation. Animate images,logos with jQuery Animer des images, des logos avec jQuery

    blog comments powered by Disqus Commentaires Blog powered by Disqus