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 Oppdateringer via RSS | Epost Get updates via feedburner Get updates via twitter
Home / Apps / Coding / JavaScript & Ajax / PHP / JavaScript: Get anchor from … Hjem / Apps / Coding / JavaScript og Ajax / PHP / JavaScript: Få anker fra ...

JavaScript: Get anchor from URL JavaScript: Få anker fra URL

Posted on 10. Posted on 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Jun 2009 av Dragos i Apps, Coding, JavaScript og Ajax, PHP

To get the anchor from an URL (this is the text after the # character) in JavaScript you can use the following code: For å få ankeret fra en URL (dette er teksten etter # tegnet) i JavaScript kan du bruke følgende kode:

 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'; / / hvis du trenger å ta den aktuelle nettadressen til vinduet bruk: var url = window.location;
var anchor=url.hash; //anchor with the # character var anker = url.hash; / anker med #-tegn
var anchor2=url.hash.substring(1); //anchor without the # character var anchor2 = url.hash.substring (1); / / anker uten # tegn 

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: Hvis du iterating gjennom linker i en side med jQuery, og $ (denne) definerer en enkelt kobling, og deretter å finne feste av dette objektet du trenger for å bruke følgende kode:

 var anchor=$(this).attr("hash"); var anker = $ (denne). attr ( "hash"); 
Translate this post Oversett dette innlegget


Related posts: Relaterte artikler:

  1. Javascript: How to validate email address with JavaScript? Javascript: Hvordan kan validere e-postadressen med JavaScript?
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Hvordan få indeksen (posisjon innenfor en gruppe) av et objekt med jQuery?
  3. JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Send fungere som en parameter til en annen funksjon (tilbakeanrop)
  4. JavaScript: What if jQuery animation doesn't fire/start? JavaScript: Hva hvis jQuery animasjon ikke brann / start?
  5. JavaScript: GIFless animation. JavaScript: GIFless animasjon. Animate images,logos with jQuery Animere bilder, logoer med jQuery

    blog comments powered by Disqus Bloggen kommentarer drevet av Disqus