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 FRISSÍTÉSEK VIA RSS | E-mail Get updates via feedburner Get updates via twitter
Home / Apps / Coding / JavaScript & Ajax / PHP / JavaScript: Get anchor from … Home / Apps / Kódolás / JavaScript és Ajax / PHP / JavaScript: Get horgony-tól ...

JavaScript: Get anchor from URL JavaScript: Get horgony az URL-ből

Posted on 10. Posted 10-én. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Június, 2009 Dragos az Apps, Coding, JavaScript és Ajax, PHP

To get the anchor from an URL (this is the text after the # character) in JavaScript you can use the following code: Ahhoz, hogy a horgony egy URL-t (ez a szöveg után a # karaktert) JavaScript használhatja a következő kódot:

 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 "/ / Ha meg kell hozniuk a jelenlegi url-jét, az ablak használni: var url = window.location; 
 var anchor=url.hash; //anchor with the # character var anchor = url.hash / / horgony a # karaktert 
 var anchor2=url.hash.substring(1); //anchor without the # character var anchor2 = url.hash.substring (1); / / horgony nélkül, a # karaktert 

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: Ha iterációjával kapcsolatokon keresztül egy oldalt JQuery, és $ (this) határozza meg egy linkre, majd megtalálni a horgonyt ezen objektum lenne szüksége, hogy az alábbi kód:

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


Related posts: Related posts:

  1. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Hogyan juthat az index (position csoportján belül) egy objektum jQuery?
  2. Javascript: How to validate email address with JavaScript? Javascript: How to validate e-mail címét a JavaScript?
  3. JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Send függvény paraméterként egy másik funkció (visszahívások)
  4. JavaScript: What if jQuery animation doesn't fire/start? JavaScript: mi van, ha jQuery animáció nem villan / start?
  5. JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Hol találok Minden tulajdonság minden HTML elemek?

    blog comments powered by Disqus iPhone Disqus szerint