JavaScript: Get anchor from URL JavaScript: URL'den çapa alın
Posted on 10. 10 olarak gönderildi. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Haziran, 2009 Apps, Kodlama, JavaScript ve Ajax, PHP ve Dragos tarafından
To get the anchor from an URL (this is the text after the # character) in JavaScript you can use the following code: Bir URL'den çapa almak için (bu # karakterden sonra metin) JavaScript aşağıdaki kodu kullanabilirsiniz:
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'; / / eğer pencere kullanım mevcut url almak için: var url = window.location gerekir; var anchor=url.hash; //anchor with the # character var anchor = url.hash; # karakteri ile / / çapa var anchor2=url.hash.substring(1); //anchor without the # character # karakteri olmadan var anchor2 = url.hash.substring (1); / / çapa
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: Eğer JQuery ile bir sayfadaki bağlantıları sayesinde, iterating konum ve $ (bu), daha sonra bu nesnenin size aşağıdaki kodu kullanabilirsiniz gerekiyordu çapa bulmak için tek bir bağlantı tanımlar:
var anchor=$(this).attr("hash"); var anchor = $ (this). attr ( "hash"); Related posts: Ilgili posta:
- Javascript: How to validate email address with JavaScript? Javascript: Nasıl JavaScript ile e-posta adresinizi doğrulamak için?
- JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: jQuery ile nasıl bir nesnenin (konum bir grup içinde) kütüğü almak için?
- JavaScript: Send function as a parameter to another function (callbacks) JavaScript: başka bir işlev (geriçağırımları) bir parametre olarak işlev gönder
- JavaScript: What if jQuery animation doesn't fire/start? JavaScript: Ya jQuery animasyon olmayan yangın / başlar?
- JavaScript: GIFless animation. JavaScript: GIFless animasyon. Animate images,logos with jQuery Animate görüntüler, jQuery ile logolar












































