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 CẬP NHẬT VIA RSS | Email Get updates via feedburner Get updates via twitter
Home / Apps / Coding / JavaScript & Ajax / PHP / JavaScript: Get anchor from … Trang chủ / Apps / Coding / JavaScript & Ajax / PHP / JavaScript: Nhận neo từ ...

JavaScript: Get anchor from URL JavaScript: Nhận neo từ URL

Posted on 10. Được đăng trên 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Tháng Sáu, 2009 bởi Dragos trong 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: Để có được neo từ một URL (đây là văn bản sau khi ký tự #) trong JavaScript bạn có thể sử dụng mã sau:

 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'; / / nếu bạn cần lấy url hiện tại của việc sử dụng cửa sổ: var url = window.location;
var anchor=url.hash; //anchor with the # character var anchor = url.hash; / / neo với các ký tự #
var anchor2=url.hash.substring(1); //anchor without the # character var anchor2 = url.hash.substring (1); / / neo mà không có ký tự # 

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: Nếu bạn đang iterating thông qua các liên kết trong một trang với JQuery, và $ (này) định nghĩa một liên kết duy nhất, sau đó để tìm neo của đối tượng này bạn cần phải sử dụng các mã sau:

 var anchor=$(this).attr("hash"); var anchor = $ (này). attr ( "băm"); 
Translate this post Dịch bài đăng này


Related posts: Liên quan đến bài viết:

  1. Javascript: How to validate email address with JavaScript? Javascript: Làm thế nào để xác nhận địa chỉ email bằng Javascript?
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Làm thế nào để có được chỉ số (vị trí trong một nhóm) của một đối tượng với jQuery?
  3. JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Gửi chức năng như một tham số đến một chức năng (callbacks)
  4. JavaScript: What if jQuery animation doesn't fire/start? JavaScript: jQuery hoạt hình gì nếu không cháy / bắt đầu?
  5. JavaScript: GIFless animation. JavaScript: GIFless hoạt hình. Animate images,logos with jQuery Animate hình ảnh, logo với jQuery

    blog comments powered by Disqus blog ý kiến được hỗ trợ bởi are On