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アップデートのVIA のRSS | メール 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 6月、2009 アプリ符号化の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;ヴァールのURL ='http://iwebdevel.com/some-post#コメント- 1'; / /場合は、ウィンドウを使用するのは現在のURLにする:ヴァールのURL = window.locationの必要があります。
var anchor=url.hash; //anchor with the # characterヴァールアンカー= url.hash;#文字で/ /アンカー
var anchor2=url.hash.substring(1); //anchor without the # character #文字を使用せずヴァール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を使ってページ内のリンクを介して、反復していると$(this)は、次に、このオブジェクトの場合は、次のコードを使用する必要があるだろうがアンカーを見つけるために1つのリンクを定義します:

 var anchor=$(this).attr("hash");ヴァールアンカー= $(この)。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 ブログのコメントディスカスによって供給さ