单击 Safari 5.1 选择菜单刷新页面
这既是一个问题,也是一个答案。我今天遇到了一个错误,这是我作为 Web 开发人员多年来从未见过的错误,因此我想与将来可能遇到该问题的任何人分享修复程序。我也很好奇是否有其他人经历过这种情况,以及是否有已知的原因。
此问题是 Mac 上的 Safari 5.1 所独有的。当单击选择下拉菜单时,页面将完全刷新。经过几分钟的调试,我得出结论,该错误是由......等等......在选择框上放置一个CSS边框引起的。 (边框:1px 实线#ccc;)
WTF?
显然,Safari 的渲染引擎不喜欢这种风格,它破坏了整个页面。只有 Safari 5.1(5.0.3 就可以了),而且只能在 Mac 上使用。
当它发生时,在我公司的多个应用程序上,它是 100% 可重现的。但它并不是 100% 普遍可复制的,这意味着我不能随机访问任何网站并触发它。它必须是触发它的 CSS 规则或 html 标记的某种组合。
还有其他人见过这个吗?有什么具体情况可能导致这种情况的见解吗?如果没有,哦,好吧。我会将其归因于浏览器错误,并将这篇文章留给其他开发人员,以便他们在遇到相同问题时查找。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
最终答案:
我找到了针对我们网站上特别遇到的问题的最终解决方案。网站加载后,我们使用 TypeKit 库将字体附加到页面。当我专门将选择框上的 font-family 属性设置为 TypeKit 字体以外的其他字体时,刷新行为不再出现。
我不确定您是否使用 TypeKit,但这将是首先查看的好地方。
原始答案:
我今天在我公司运营的一个网站上也遇到了这个问题。我已将其范围缩小到一组最有可能导致该问题的 CSS 规则(注释掉这些规则不会在页面重新加载时产生错误)。
我看到的主要问题很可能是浏览器本身的安全问题。如果您在任何选项卡中有任何打开的会话,它也会清除其会话数据。
找到存在此错误的页面,然后打开其他几个选项卡,您可以在其中登录 Google 帐户或其他帐户组。当您单击存在错误的站点上的选择框时,页面将刷新,其他选项卡中的会话也会重置。
更新:
我已经缩小了影响我们页面的 CSS 规则集的范围。这些CSS规则中的任何一个都会导致这种行为:
我最初认为它是 -background-image 属性这导致了问题,因为我们使用的是数据图像,而不是实际的 png 或 jpg (以提供样式与默认类似在 Firefox 中),但我显然错了。
更新 2: 我尝试使用 CSS 重置,使用 webkit 特定的 CSS hack,但仅仅触及这些 CSS 规则中的任何一个似乎都会导致事情变得混乱。我想我们需要删除这些规则,直到解决这个问题。
更新3:这似乎与页面上加载的Javascript有关。如果我在 Safari 中禁用 Javascript,则不会发生这种情况。
Final Answer:
I found a final fix for the problem we were specifically having on our site. After the site loads, we have the TypeKit library attaching fonts to the page. When I specifically set the font-family property on the select boxes to something other than the TypeKit font, the refresh behavior no longer presents itself.
I'm not sure if you're using TypeKit or not, but that would be a good place to look first.
Original Answer:
I encountered this issue as well today on one of the sites that my company runs. I had narrowed it down to a set of CSS rules that were most likely causing it (commenting those out would not produce the bug on page reload).
The main issue I see with this could very well be a security issue in the browser itself. If you have any open sessions in any tabs, it will clear their session data as well.
Find a page that has this bug, and open several other tabs where you log into a Google account, or some other set of accounts. When you click the select boxes on the site with the bug, the page is refreshed, and the sessions in the other tabs are reset as well.
Update:
I have narrowed down the set of CSS rules that are affecting our page. Any one of these CSS rules will cause this behavior:
I had originally thought that it was the -background-image property that was causing issues, as we're using a data image, instead of an actual png or jpg (to give a style similar to the default in Firefox), but I was apparently wrong.
Update 2: I tried using CSS resets to put things back to normal using a webkit-specific CSS hack, but just touching any of these CSS rules seems to cause things to go haywire. I guess we will need to just remove the rules until there is a fix for this.
Update 3: It seems to have something to do with the Javascript being loaded on the page. If I disable Javascript in Safari, this does not happen.
您应该提交错误报告: https://bugs.webkit.org/
这样,该错误就会 (希望!)得到修复,以便未来的开发人员永远不会遇到它。
此问题不久前已得到修复:https://bugs.webkit.org/show_bug .cgi?id=65350
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
我还遇到了页面重新加载/会话清除错误。
所以这就是我从你的答案中发现的一些内容...
在一个页面上我使用 GoogleFonts,并像这样应用 CSS:
Safari 似乎讨厌你将网络字体应用于选择或选项标签。将代码更改为此问题就消失了。
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:
It seems Safari hates when you apply web fonts to select or option tags. Changing the code to this made the problem go away.
我也有这个问题。我通过删除所有选择的'font-face'指令解决了这个问题
I had this issue too. I solved it by removing the 'font-face' instruction for all selects
我也遭受过这种痛苦 - 更确切地说,我热爱 Safari 的老板也遭受过这种痛苦!不相信他的浏览器中会出现“但是”。这里有更多关于错误的确认:http://redrata.com /2011/07/safari-woff-select-field-crash/
希望他们能尽快修复它,同时坚持使用网络安全字体。 Chrome 是否会好起来,因为它也是基于 WebKit 构建的,或者代码库有足够的不同......
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...
我也有同样的问题,我发现主要问题是由于CSS检查CSS以在您单击MAC中的下拉菜单时停止重新加载而发生的
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
我也遇到了同样的问题,我通过将特定于 Safari 11 和 Safari 的自定义 CSS 解决了它。 12 通过使用jquery-browser插件来检测浏览器,如果是Safari 11或12,那么我在文档的头部内部动态添加以下样式。
设置
inherit
可以让您保持相同的外观和感觉。希望这有帮助!
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.
Putting
inherit
allows you to keep the same look and feel.Hope this helps!