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 UPDATES VIA RSS | E-pasts Get updates via feedburner Get updates via twitter
Home / Apps / Coding / JavaScript & Ajax / PHP / JavaScript: Get anchor from … Home / Apps / kodēšanas / JavaScript un Ajax / PHP / JavaScript: Get enkuru no ...

JavaScript: Get anchor from URL JavaScript: Get enkuru no URL

Posted on 10. Posted on 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Jun, 2009 by Dragos in Apps, kodēšana, JavaScript un Ajax, PHP

To get the anchor from an URL (this is the text after the # character) in JavaScript you can use the following code: Lai iegūtu enkurs no URL (tas ir pēc # rakstzīmju tekstu) in JavaScript varat izmantot šādu kodu:

 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 "; / / ja Jums ir nepieciešams veikt pašreizējā URL loga izmantot: var url = window.location;
var anchor=url.hash; //anchor with the # character var noenkuroties = url.hash; / / enkuru ar # raksturs
var anchor2=url.hash.substring(1); //anchor without the # character var anchor2 = url.hash.substring (1); / / enkuru bez # raksturs 

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: Ja jūs atkārtojot caur in lapu ar jquery saites un $ (this) nosaka vienu saiti, tad atrast enkuru par šo objektu vēlaties nepieciešams izmantot šādu kodu:

 var anchor=$(this).attr("hash"); var enkurs = $ (this). attr ( "kapāta gaļa"); 
Translate this post Tulkot šo ziņu


Related posts: Related posts:

  1. Javascript: How to validate email address with JavaScript? Javascript: Kā lai apstiprinātu e-pasta adresi ar JavaScript?
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Kā nokļūt indekss (amatu grupā) un objekts ar jQuery?
  3. JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Sūtīt funkcija kā parametru citai funkcijai (callbacks)
  4. JavaScript: What if jQuery animation doesn't fire/start? JavaScript: Ko darīt, ja jQuery animācijas nav uguns / sākt?
  5. JavaScript: GIFless animation. JavaScript: GIFless animāciju. Animate images,logos with jQuery Dzīva attēlus, logotipus ar jQuery

    blog comments powered by Disqus blog komentāriem powered by Disqus