JavaScript: Get anchor from URL JavaScript: Get sidro iz URL-a
Posted on 10. Poslano na 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Jun, 2009 by Dragos u Apps, kodiranju, JavaScript i Ajax, PHP
To get the anchor from an URL (this is the text after the # character) in JavaScript you can use the following code: Da biste dobili sidro iz URL-a (ovo je tekst iza znaka #) u JavaScriptu možete koristiti sljedeći 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'; / / ako morate uzeti trenutne url prozora uporabe: var url = window.location; var anchor=url.hash; //anchor with the # character var sidro = url.hash; / / sidro sa # znak var anchor2=url.hash.substring(1); //anchor without the # character var anchor2 = url.hash.substring (1), / / Anchor, bez znakova #
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: Ako ste iterating preko veze u stranici s jQuery, i $ (ova) definira jednu vezu, a zatim pronaći sidro ovog objekta youd 'trebate koristiti sljedeći kod:
var anchor=$(this).attr("hash"); var sidro = $ (this). attr ( "haš"); Related posts: Related posts:
- Javascript: How to validate email address with JavaScript? Javascript: Kako da biste provjerili valjanost adresa e-pošte s JavaScriptom?
- JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Kako biste dobili indeks (poziciju unutar grupe) s jQuery objekt?
- JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Pošaljite funkcija kao parametar za druge funkcije (callbacks)
- JavaScript: What if jQuery animation doesn't fire/start? JavaScript: Što ako jQuery animacija ne požara / početi?
- JavaScript: GIFless animation. JavaScript: GIFless animacija. Animate images,logos with jQuery Animate slike, logotipi s jQuery












































