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 Päivitykset RSS | Sähköposti Get updates via feedburner Get updates via twitter
Home / Apps / Coding / JavaScript & Ajax / PHP / JavaScript: Get anchor from … Etusivu / sovellukset / koodaus / JavaScript ja Ajax / PHP / JavaScript: Hanki ankkuri from ...

JavaScript: Get anchor from URL JavaScript: Hanki ankkuri URL-osoitteesta

Posted on 10. Postitettu 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Kesäkuu, 2009 Dragos ja sovellukset, Coding, JavaScript-ja Ajax, PHP

To get the anchor from an URL (this is the text after the # character) in JavaScript you can use the following code: Saada ankkuri alkaen URL (tämä on tekstin jälkeen #-merkki) JavaScript voit käyttää seuraavaa koodia:

 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" / / jos haluat ottaa nykyistä URL-ikkunan käyttö: var url = window.location; 
 var anchor=url.hash; //anchor with the # character var ankkuri = url.hash, / ankkuri on #-merkki 
 var anchor2=url.hash.substring(1); //anchor without the # character var anchor2 = url.hash.substring (1), / / ankkuri ilman #-merkki 

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: Jos olet iteroimalla läpi linkit sivun kanssa jQuery, ja $ (tämä) määritellään yksi linkki, sieltä löytää ankkuri tämän kohteen sinun tulee käyttää seuraavaa koodia:

 var anchor=$(this).attr("hash"); var ankkuri = $ (tämä). attr ( "hash"); 
Translate this post Käännä tämä viesti


Related posts: Liittyvien virkojen:

  1. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Miten saada indeksi (asema ryhmä) objektin kanssa jQuery?
  2. Javascript: How to validate email address with JavaScript? Javascript: Miten vahvistaa sähköpostiosoitteesi JavaScript?
  3. JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Lähetä toimivat parametri toisen toiminnon (kutsuja)
  4. JavaScript: What if jQuery animation doesn't fire/start? JavaScript: Mitä jos jQuery animaatio ei palo / alku?
  5. JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Mistä löydän kaikki ominaisuudet kaikki HTML-elementit?

    blog comments powered by Disqus blogin kommentit powered by Disqus