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 get the index (position within a group) of an object with jQuery? JavaScript: Как получить индекс (позиция в группе) объекта с JQuery?
  2. Javascript: How to validate email address with JavaScript? JavaScript: Как проверить адрес электронной почты с JavaScript?
  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: Where do I Find All Properties for All HTML Elements ? JavaScript: Где мне найти свойства для всех элементов HTML?

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