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 3 years have passed since last update.

safari アンカーリンク付きページ遷移時 offsetTopを0で返してくれない

1
Last updated at Posted at 2021-07-17

この書き方で検証

$(function () {
   $(window).on('load', function() {
    console.log($('body,html').offset().top);
} 

Chromeの場合
この様なurlでページ遷移した時、コンソールログは「0」
https://qiita.com/drafts/edit#qiita

Safariの場合
この様なurlでページ遷移した時、コンソールログは「-1111」
アンカーリンクのある場所からの数値
https://qiita.com/drafts/edit#qiita

つまり
Chromeはページ遷移時、アンカーリンクのある場所の値を返さない。
Safariはページ遷移時、アンカーリンクのある場所の値を返す。

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?