1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

IEのみsvg "viewBox"の値が変更できないとき

Posted at

正確には、svgのviewBoxの値を取得した時の問題

 svg.attr("viewBox")

でviewBoxの値を取得し、
配列に格納し、3番目のパラメータ(幅)と4番目のパラメータ(高さ)を
変更して、再度viewBoxを設定しようとしたら、

属性が空っぽになった。 viewBox=""

原因は、
viewBoxの値を取得した時に、chromeではカンマ+空白、IEは空白のみ。
それに気づかずxとyの取得のため、
split(",")
で切り分けていた。

で、めちゃくちゃな値を設定したので、属性を変更した時に、変更できずに属性が空っぽになった。
切り分けを
split(" ")
に変更したら、IEでもviewBoxの値が変更できた。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?