JavaScript: Get anchor from URL JavaScript: Get inkaro iš URL
Posted on 10. Posted on 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Birželis, 2009 Dragos į Apps ", kodavimo, JavaScript ir Ajax, PHP,
To get the anchor from an URL (this is the text after the # character) in JavaScript you can use the following code: Gauti iš URL inkaro (tai yra po # pobūdžio tekstas), JavaScript, galite naudoti šį kodą:
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 "/ / jei jums reikia priimti dabartinis URL langą naudoti: var url = window.location; var anchor=url.hash; //anchor with the # character var anchor = url.hash; / / Anchor su # pobūdis var anchor2=url.hash.substring(1); //anchor without the # character var anchor2 = url.hash.substring (1), / / Anchor be # pobūdis
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: Jei esate Iteracja per į su JQuery nuorodų puslapyje, ir $ $ (this) apibrėžia vieną nuorodą, ten rasti šio objekto inkaro jums reikia naudoti šį kodą:
var anchor=$(this).attr("hash"); var anchor = $ (this). attr ( "hash"); Related posts: Related posts:
- Javascript: How to validate email address with JavaScript? Javascript: Kaip patvirtinti elektroninio pašto adresą su "JavaScript?
- JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Kaip gauti indeksą (pozicijos grupės) su jQuery objektas?
- JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Siųsti funkcija kaip parametro kitos funkcijos (Atgalinės iššūkius)
- JavaScript: What if jQuery animation doesn't fire/start? JavaScript: Ką daryti, jei jQuery animacija nėra gaisro / paleisti?
- JavaScript: GIFless animation. JavaScript: GIFless animacija. Animate images,logos with jQuery Gyva nuotraukų, logotipų su jQuery












































