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 Оновлення через RSS | Email Get updates via feedburner Get updates via twitter
Home / Apps / Coding / JavaScript & Ajax / PHP / JavaScript: Get anchor from … Головна / Служби / кодування / JavaScript & Ajax / PHP / JavaScript: Отримати якір, з ...

JavaScript: Get anchor from URL JavaScript: Отримати якір, з URL

Posted on 10. Опублікований 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Червень, 2009 Dragos в Службі, кодування, 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: Щоб отримати якір, з URL (це текст після символу #) В JavaScript ви можете використовувати наступний код:

 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-1'; / / якщо ви хочете взяти поточний URL з вікна використовувати: VAR URL = window.location;
var anchor=url.hash; //anchor with the # character VAR = Якір url.hash / / якір з символу #
var anchor2=url.hash.substring(1); //anchor without the # character VAR anchor2 = url.hash.substring (1); / / якір без символу # 

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: Якщо ви ітерації за посиланнями на сторінці з JQuery і $ (це) визначає одне посилання, а потім, щоб знайти якір цей об'єкт ви повинні використовувати наступний код:

 var anchor=$(this).attr("hash"); VAR якір = $ (це). Attr ( "хеш"); 
Translate this post Перекласти цю посаду


Related posts: Схожі повідомлення:

  1. Javascript: How to validate email address with JavaScript? JavaScript: Як перевірити адресу електронної пошти з JavaScript?
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Як отримати індекс (позиція в групі) об'єкта з JQuery?
  3. JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Надіслати функцію як параметр в іншу функцію (функції зворотного виклику)
  4. JavaScript: What if jQuery animation doesn't fire/start? JavaScript: Що робити, якщо Jquery анімація не спрацьовує / почати?
  5. JavaScript: GIFless animation. JavaScript: GIFless анімації. Animate images,logos with jQuery Анімація зображення, логотипи з JQuery

    blog comments powered by Disqus Блог коментарі сила Disqus