Home > Archives > 2007年12月 > IE6+外部JSにおいてa要素のhref属性を取得すると勝手にデコードされてしまう問題とその解決法

IE6+外部JSにおいてa要素のhref属性を取得すると勝手にデコードされてしまう問題とその解決法

IE6+外部JSにおいてa要素のhref属性を取得すると勝手にデコードされてしまう問題とその解決法

現象

IE6+外部JSにおいてa要素のhref属性をelement.hrefもしくはelement.getAttribute("href")のような形で取得すると、URLエンコードされた文字列が勝手にバイナリ文字列にデコードされてしまう。

解決法

element.getAttribute("href", 2)に置き換えれば解決。

参照

getAttribute Method (A, ADDRESS, APPLET, ...) | MSDN Internet Explorer Developer Center

iFlags

Optional. Integer that specifies one or more of the following flags:

0
Default. Performs a property search that is not case-sensitive, and returns an interpolated value if the property is found.
1
Performs a case-sensitive property search. To find a match, the uppercase and lowercase letters in sAttrName must exactly match those in the attribute name. If the iFlags parameter for getAttribute is set to 1 and this option is set to 0 (default), the specified property name might not be found.
2
Returns the value exactly as it was set in script or in the source document.

例によってIE独自規格。

Comment: 0

Attention
コメントの受け付けは終了しました。

Trackback: 0

Attention
トラックバックの受け付けは終了しました。

Home > Archives > 2007年12月 > IE6+外部JSにおいてa要素のhref属性を取得すると勝手にデコードされてしまう問題とその解決法

Feeds
Counter
  • Counter

    since 2008.01.11

Page Top