LoginSignup
1
0

More than 5 years have passed since last update.

history.pushState対応をブラウザ判定に使うと危険

Posted at

新しく作ったIE9以下に対応していないサイトで、IE9以下をはじくために

HTML
<script>if(!history.pushState) location.replace("/legacy.html")</script>

みたいな感じで、legacy.htmlに飛ばすコードを全てのページに書いていたところ、Googleの検索結果が全てのページでlegacy.htmlの内容になってしまい、意図したキーワードで検索にヒットしなくなりました。
googlebot?はhistory.pushState非対応のようで注意が必要だというお話でした。

こういう場合、素直に以下のようなコードにしましょう!

HTML
<!--[if lte IE 9]>"}}<script>location.replace("/legacy.html")</script>
1
0
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
0