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 Posodobitev prek RSS | Email Get updates via feedburner Get updates via twitter
Home / Apps / Coding / JavaScript & Ajax / PHP / JavaScript: Get anchor from … Domov / Apps / Kodiranje / JavaScript in Ajax / PHP / JavaScript: Get sidro od ...

JavaScript: Get anchor from URL JavaScript: Get sidro iz URL-ja

Posted on 10. Objavljeno dne 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Junij 2009, ki ga Dragos v Apps, Coding, JavaScript in Ajax, PHP

To get the anchor from an URL (this is the text after the # character) in JavaScript you can use the following code: Če želite sidro iz URL (to je besedilo za znak #), v JavaScript lahko uporabite naslednjo kodo:

 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 ga potrebujete, da sedanje url okna uporabe: var url = window.location;
var anchor=url.hash; //anchor with the # character var sidro = url.hash; / / sidra z # značaja
var anchor2=url.hash.substring(1); //anchor without the # character var anchor2 = url.hash.substring (1); / / sidro, ne da bi # značaja 

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 ste iterating prek povezav na strani s jQuery, in $ (this) opredeljuje eno povezavo, nato pa, da bi našli sidro tega predmeta, ki ga bi morali uporabiti naslednjo kodo:

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


Related posts: Podobni objav:

  1. Javascript: How to validate email address with JavaScript? Javascript: kako potrditi e-naslov z JavaScript?
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Kako indeks (položaj v skupini) predmeta s jQuery?
  3. JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Pošljite funkcijo kot parameter na drugo delovno mesto (callbacks)
  4. JavaScript: What if jQuery animation doesn't fire/start? JavaScript: Kaj če jQuery animacije ne ognja / začeti?
  5. JavaScript: GIFless animation. JavaScript: GIFless animacije. Animate images,logos with jQuery Animate slike, logotipi s jQuery

    blog comments powered by Disqus blog comments powered by Disqus