ウェブサービスを作っています。

location.href, document.URL のエンコードがブラウザによってバラバラな件

http://ja.wikipedia.org/wiki/メインページ」を開いて、ロケーションバーに

javascript:alert(%22location.href:%22+location.href+%22\ndocument.URL:%22+document.URL)

と打ち込む。ちなみに、この内容は

alert("location.href:" + location.href + "\ndocument.URL:" + document.URL)

です。結果は、


Firefox3:

location.href:http://ja.wikipedia.org/wiki/%E3%83%A1%E3%82%A4%E3%83%B3%E3%83%9A%E3%83%BC%E3%82%B8
document.URL:http://ja.wikipedia.org/wiki/%E3%83%A1%E3%82%A4%E3%83%B3%E3%83%9A%E3%83%BC%E3%82%B8

Safari3:

location.href:http://ja.wikipedia.org/wiki/メインページ
document.URL:http://ja.wikipedia.org/wiki/%E3%83%A1%E3%82%A4%E3%83%B3%E3%83%9A%E3%83%BC%E3%82%B8

Opera9:

location.href:http://ja.wikipedia.org/wiki/メインページ
document.URL:http://ja.wikipedia.org/wiki/メインページ

IE7:

location.href:http://ja.wikipedia.org/wiki/メインページ
document.URL:http://ja.wikipedia.org/wiki/メインページ


エンコードして統一。

encodeURI(decodeURI(location.href))