JavaScript: Get anchor from URL 자바 스크립트 : URL에서 앵커로 나가
Posted on 10. 10 게시됨. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP 6 월, 2009 애플 리케이션, 코딩, 자바 스크립트 & 아약스, PHP는에서 드라 고스에 의해
To get the anchor from an URL (this is the text after the # character) in JavaScript you can use the following code: URL의 앵커를 얻으려면 (이것은 # 문자 뒤의 문자) 자바 스크립트에서 다음과 같은 코드를 사용할 수있습니다 :
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와 페이지에서 링크를 통해, iterating하고 $ (이), 다음이 개체의 다음과 같은 코드를 사용이 필요 할 걸요 앵커를 찾을 단일 링크를 정의합니다 :
var anchor=$(this).attr("hash"); var 앵커 = $ (이). attr ( "해시"); Translate this post 번역이 게시물에
Related posts: 관련 게시물 :
- Javascript: How to validate email address with JavaScript? 자바 스크립트 : 자바 스크립트와 방법의 이메일 주소를 확인하려면?
- JavaScript: How to get the index (position within a group) of an object with jQuery? 자바 스크립트 : 어떻게 jQuery와 개체의 (위치를 그룹 내에서) 인덱스를 얻을가?
- JavaScript: Send function as a parameter to another function (callbacks) 자바 스크립트 : 다른 함수 (콜백)를 매개 변수로 함수를 보내기
- JavaScript: What if jQuery animation doesn't fire/start? 자바 스크립트 : 어떤 경우에는 jQuery 애니메이션 쏘지 / 시작합니까?
- JavaScript: GIFless animation. 자바 스크립트 : GIFless 애니메이션. Animate images,logos with jQuery 애니메이션 이미지를 jQuery와 로고












































