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: Dapatkan jangkar dari ...

JavaScript: Get anchor from URL JavaScript: Dapatkan jangkar dari URL

Posted on 10. Dikirim di 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Jun, 2009 oleh Dragos dalam 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: Untuk mendapatkan jangkar dari sebuah URL (ini adalah teks setelah # karakter) dalam JavaScript Anda dapat menggunakan kode berikut:

 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'; / / jika Anda perlu untuk mengikuti arus url jendela menggunakan: var url = window.location;
var anchor=url.hash; //anchor with the # character var jangkar = url.hash; / / anchor dengan karakter #
var anchor2=url.hash.substring(1); //anchor without the # character var anchor2 = url.hash.substring (1); / / anchor tanpa 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: Jika Anda iterasi melalui link pada halaman dengan JQuery, dan $ (ini) mendefinisikan sebuah link, kemudian untuk menemukan jangkar objek ini Anda akan perlu menggunakan kode berikut:

 var anchor=$(this).attr("hash"); var anchor = $ (ini). attr ( "hash"); 
Translate this post Terjemahkan posting ini


Related posts: Related posts:

  1. Javascript: How to validate email address with JavaScript? Javascript: Bagaimana untuk memvalidasi alamat email dengan JavaScript?
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Cara mendapatkan indeks (posisi dalam grup) dari sebuah objek dengan jQuery?
  3. JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Kirim fungsi sebagai parameter ke fungsi lain (callback)
  4. JavaScript: What if jQuery animation doesn't fire/start? JavaScript: Bagaimana jika tidak animasi jQuery api / start?
  5. JavaScript: GIFless animation. JavaScript: GIFless animasi. Animate images,logos with jQuery Bernyawa gambar, logo dengan jQuery

    blog comments powered by Disqus blog comments powered by DISQUS