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 | Email Get updates via feedburner Get updates via twitter
Home / Apps / Coding / JavaScript & Ajax / PHP / JavaScript: Get anchor from … Home / Apps / Coding / JavaScript & Ajax / PHP / JavaScript: Kumuha ng anchor mula sa ...

JavaScript: Get anchor from URL JavaScript: Kumuha ng mga anchor mula sa URL

Posted on 10. Posted on 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Hunyo, 2009 sa pamamagitan ng Dragos sa Apps, Coding, JavaScript & Ajax, PHP

To get the anchor from an URL (this is the text after the # character) in JavaScript you can use the following code: Upang makuha ang anchor mula sa isang URL (ito ay ang text matapos ang # ng character) sa JavaScript maaari mong gamitin ang sumusunod na code:

 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'; / / kung kailangan mo ng gawin ang kasalukuyang url ng gamitin ang window: var url = window.location;
var anchor=url.hash; //anchor with the # character var anchor = url.hash; / / anchor sa # na karakter
var anchor2=url.hash.substring(1); //anchor without the # character var anchor2 = url.hash.substring (1); / / anchor ng walang # na karakter 

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: Kung ikaw ay iterating sa pamamagitan ng mga link sa isang pahina na may JQuery, at $ (na ito) tumutukoy sa isang link, pagkatapos ay upang mahanap ang anchor ng object na gusto mong gamitin ang sumusunod na code:

 var anchor=$(this).attr("hash"); var anchor = $ (ito). attr ( "sumira"); 
Translate this post Isalin ang post na ito


Related posts: Related posts:

  1. Javascript: How to validate email address with JavaScript? Javascript: Paano upang mapatunayan ang email address sa JavaScript?
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Paano upang makuha ang index (na posisyon sa loob ng isang grupo) ng isang bagay na may jQuery?
  3. JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Ipadala ang function bilang isang parameter sa isa pang function (callbacks)
  4. JavaScript: What if jQuery animation doesn't fire/start? JavaScript: Paano kung jQuery animation ay hindi sunog / simulan?
  5. JavaScript: GIFless animation. JavaScript: GIFless animation. Animate images,logos with jQuery Magpasaya mga imahe, mga logo na may jQuery

    blog comments powered by Disqus blog comments powered by Disqus