LoginSignup
6
5

More than 5 years have passed since last update.

IEはanchorタグのpathnameとlocationのpathnameで違う値を返す

Posted at

IE で anchor タグの pathname プロパティを取得すると、先頭のスラッシュ(/)が無い。

URL が http://hoge.com/fuga/piyo の場合、

Firefox と Chrome は anchor も location も pathname プロパティは /fuga/piyo を返す。
IE の場合は anchor の pathname が fuga/piyo を返し、 location の pathname が /fuga/piyo を返す。

area タグの pathname プロパティも anchor タグと同じで、 IE の場合は先頭のスラッシュが無い。

サンプル
http://jsfiddle.net/opengl_8080/UsXyh/

参考

6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5