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:関連記事:
- Javascript: How to validate email address with JavaScript? Javascriptを:どのようにJavaScriptを使って電子メールアドレスを検証する?
- JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScriptを:どのようにjQueryを使ってオブジェクトの(位置は 、 グループ内)のインデックスを取得する?
- JavaScript: Send function as a parameter to another function (callbacks) JavaScriptを:別の関数(コールバック)へのパラメータとして関数を送る
- JavaScript: What if jQuery animation doesn't fire/start? JavaScriptを:どのような場合はjQueryのアニメーションは火災/起動するのですか?
- JavaScript: GIFless animation. JavaScriptを:GIFlessアニメーション。 Animate images,logos with jQuery アニメーション化、画像、jQueryを使ってのロゴ












































