Clicking Safari 5.1 select menu refreshes page

2020-02-19 07:59发布

This is both a question and an answer. I encountered a bug today that I've never seen in all my years as a web developer, so I wanted to share the fix with anyone who might encounter the issue in the future. I'm also curious if anyone else has experienced it, and whether there's a known cause.

The problem is exclusive to Safari 5.1 on a Mac. When a select dropdown menu was clicked, the page would completely refresh. After a few minutes of debugging, I was able to conclude that the bug was caused by ... wait for it ... putting a css border on the select box. (border:1px solid #ccc;)

WTF?

Apparently, Safari's rendering engine doesn't like that style, and it just nuked the whole page. It was only Safari 5.1 (5.0.3 was fine) and only on Mac.

It's 100% reproducible when it's happening, on multiple applications in my company. But it's not 100% reproducible universally, meaning I can't just go to any random website and trigger it. It must be some combination of css rules or html markup that triggers it.

Has anyone else ever seen this? Any insight into what specific conditions might cause it? If not, oh well. I'll chalk it up to a browser bug and leave this post up for some other developer to find when they're having the same problem.

7条回答
男人必须洒脱
2楼-- · 2020-02-19 08:23

I also was experiencing the page reload / session clearing bug.

So here's what I found with some pointers from your answers...

On a page I was using GoogleFonts, and applying the CSS like so:

body, p, ol, ul, td, input, textarea, select, option {
  font-family: 'Droid Sans', 'Helvetica', 'Arial', sans-serif;
  font-size:   12px;
  line-height: 17px;
}

It seems Safari hates when you apply web fonts to select or option tags. Changing the code to this made the problem go away.

body {
  font-family: 'Droid Sans', 'Helvetica', 'Arial', sans-serif;
  font-size:   12px;
  line-height: 17px;
}
查看更多
ゆ 、 Hurt°
3楼-- · 2020-02-19 08:23

I had this issue too. I solved it by removing the 'font-face' instruction for all selects

查看更多
可以哭但决不认输i
4楼-- · 2020-02-19 08:31

I too suffered from this - well rather my Safari loving boss did! Didn't believe it could be a but in his browser. There is more confirmation of the error here: http://redrata.com/2011/07/safari-woff-select-field-crash/

Hopefully they will fix it soon, in the meantime stick to web safe fonts. Is Chrome going to be okay as it's built upon WebKit too, or are the code bases sufficiently different...

查看更多
ら.Afraid
5楼-- · 2020-02-19 08:36

I have also same problem and i found the main problem is occurred due to CSS check your CSS to stop reload when you click on dropdown in MAC

查看更多
ゆ 、 Hurt°
6楼-- · 2020-02-19 08:36

I also had the same problem, I solved it by putting custom CSS specific for Safari 11 & 12 by using jquery-browser plugin to detect the browser, if it was Safari 11 or 12, then I added the following style on the fly, inside the head of the document.

select {
   font-family: inherit;
}

Putting inherit allows you to keep the same look and feel.

Hope this helps!

查看更多
Root(大扎)
7楼-- · 2020-02-19 08:38

You should file a bug report: https://bugs.webkit.org/

That way, the bug will (hopefully!) get fixed so that future developers will never chance upon it.


This issue has since been fixed a while ago: https://bugs.webkit.org/show_bug.cgi?id=65350

查看更多
登录 后发表回答