以前、スマホサイトでページ内アンカーリンクが効かない件についての投稿をしました。 『スマホサイトでアンカーリンク対策してやんよ!!!』(かなり力技編) ですが、この荒技故の欠点として・・・ ①ページのコンテンツが増えたり減ったりの変動で移動すべきアンカーポイントが変わってしまう。 ②ページ内でアンカーリンクポイントが複数あった場合にそのID、Classへ遷移するための記述を増やすのはいくない!! ③そもそもイチイチ座標を取得すんのがメンドクセー!!! 以上のポイントを踏まえて改善版のスクリプトを作成します。 アドレスバー非表示スクリプトについておさらい スマホ実機でページを開いた際にアドレスバーを非表示にしてコンテンツ表示領域を広くするスクリプトについて少しおさらい。 記述その1 window.onload = function() { scrollTo(0, 0); } 尚、こちらの記述