javascript 只有手机safari打不开页面,没有网络留言

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19340129/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 15:15:15  来源:igfitidea点击:

Only mobile safari cannot open the page, no internet message

javascriptphphtmlcssmobile-safari

提问by Codebeat

At first, I don't own an iPad but some clients reports some weird problem with a website of mine on the iPad. They cannot open any page on the website, they end up with a blank page with the message: "Safari cannot open webpage as it is not connected to internet".

起初,我没有 iPad,但一些客户报告我的网站在 iPad 上出现了一些奇怪的问题。他们无法打开网站上的任何页面,最终得到一个带有消息的空白页面:“Safari 无法打开网页,因为它没有连接到互联网”。

The message is a kind of weird because the user can open other websites and they are connected to the internet. Sometimes you will see the webpage for a split second and then the same message.

该消息有点奇怪,因为用户可以打开其他网站并且它们已连接到 Internet。有时您会看到网页一瞬间,然后看到相同的消息。

Yesterday a friend of mine (he is not a programmer) brings his iPad 3 with IOS7 to test it but we cannot figure out what the problem is because Safari do not share some debug info (at least you need a mac to see debug info and I don't own a mac either).

昨天我的一个朋友(他不是程序员)带着他的带有 IOS7 的 iPad 3 来测试它,但我们无法弄清楚问题是什么,因为 Safari 不共享一些调试信息(至少你需要一个 mac 来查看调试信息和我也没有 Mac)。

I test the same version of the website locally on a Windows machine to be sure it is not a hosting problem. The same error on iPad Safari, so there is a problem with the served files.

我在 Windows 机器上本地测试了相同版本的网站,以确保它不是托管问题。iPad Safari 上出现同样的错误,因此提供的文件存在问题。

The website is programmed with PHP. What I have tested so far (and didn't lead to solution):

该网站是用 PHP 编程的。到目前为止我测试过的(并没有导致解决方案):

  • Safari: Turn off Cookies and Javascript
  • Safari: Empty cache several times
  • PHP: Turn off sending header info (disable all customized cache headers)
  • PHP: Turn off customized CSS for browser
  • PHP: Turn off embedding of sprites (base64 data embedding)
  • PHP: Turn off minifying of HTML
  • Safari:关闭 Cookie 和 Javascript
  • Safari:多次清空缓存
  • PHP:关闭发送标头信息(禁用所有自定义缓存标头)
  • PHP:关闭浏览器的自定义 CSS
  • PHP:关闭精灵嵌入(base64 数据嵌入)
  • PHP:关闭 HTML 的缩小

The problem is still there. It is very difficult to test what is going wrong without any debug info of Safari, can somebody see what going on in the safari browser that cause this error?

问题仍然存在。如果没有 Safari 的任何调试信息,很难测试出了什么问题,有人可以看到导致此错误的 safari 浏览器中发生了什么吗?

The website: http://www.meezingeninrotterdam.nl

网址:http: //www.meezingeninrotterdam.nl

And does this error also occur on the MAC version of Safari?

并且这个错误是否也出现在 Safari 的 MAC 版本上?

EDIT: Report the error to Apple: Apple Safari Error Bug Report

编辑:向 Apple 报告错误: Apple Safari 错误错误报告

UPDATE:

更新:

Think I find the reason, see also my solution. If you have an iDevice, do you want to test it to confirm? See my solution below.

想我找到原因,另见我的解决方案。如果您有 iDevice,您是否要对其进行测试以确认?请参阅下面的我的解决方案。

UPDATE 2

更新 2

See answer, answer from Apple. No solution. If you know the solution or workaround, please let me know.

请参阅答案,来自 Apple 的答案。没有解决方案。如果您知道解决方案或解决方法,请告诉我。

采纳答案by Codebeat

Oh really, now I know it for sure, Apple support sucks.

哦,真的,现在我肯定知道了,Apple 的支持很糟糕。

This is the e-mail I received today in my mailbox.

这是我今天在邮箱中收到的电子邮件。

Hello Erwinus,

Engineering has determined that your bug report is a duplicate of another issue and will be closed. 

The open or closed status of the original bug report your issue was duplicated to appears in the yellow "Duplicate of XXXXXXXX" section of the bug reporter user interface. This section appears near the top of the right column's bug detail view just under the bug number, title, state, product and rank.

Example:

13556600 User interface anomaly in OS X

State: Duplicate                   Product: OS X
Rank: 3 - Medium
---------------------------------------------------------------
Duplicate of 10535951 (Open)
---------------------------------------------------------------

Okay, now I know it is a bug but what kind of workaround can I use? Nope, no answer. When I search for the issue ID #10535951 in the Bug Reporter it cannot find it!

好的,现在我知道这是一个错误,但我可以使用什么样的解决方法?不,没有答案。当我在 Bug Reporter 中搜索问题 ID #10535951 时,它找不到!

This is the answer my friends, don't waste your time register and to report a bug to help these guys.

这是我的朋友们的答案,不要浪费时间注册并报告错误以帮助这些人。

Problem unsolved!

问题未解决!

If you know a workaround or a solutionbetter than this awful piece of support, please let me know.

如果您知道比这个可怕的支持更好的解决方法或解决方案请告诉我。

回答by SammyK

I was having this issue where Safari would return the message Safari cannot open the page because the network connection was lost.My client was having the issue but it was working fine for me. I was eventually able to replicate the issue using the iOS Simulator for an iPhone 7 on iOS 10.2.

我遇到了这个问题,Safari 会返回消息Safari cannot open the page because the network connection was lost.我的客户端有问题,但它对我来说工作正常。我最终能够在 iOS 10.2 上使用适用于 iPhone 7 的 iOS 模拟器复制该问题。

The server is running Ubuntu 14.04 (trusty) using nginx 1.4.6 and the site is using a SSL/TLS cert from Let's Encrypt.

该服务器使用 nginx 1.4.6 运行 Ubuntu 14.04(可信),并且该站点使用来自Let's Encrypt的 SSL/TLS 证书。

I monitored the error log using sudo tail -f /var/log/nginx/error.log

我使用以下方法监视错误日志 sudo tail -f /var/log/nginx/error.log

Each time I refreshed the site in the iPhone simulator, it generated three new error messages on the server:

每次我在 iPhone 模拟器中刷新站点时,都会在服务器上生成三个新的错误消息:

2016/12/22 17:48:39 [alert] 8071#0: worker process 12812 exited on signal 11 (core dumped)
2016/12/22 17:48:39 [alert] 8071#0: worker process 12848 exited on signal 11 (core dumped)
2016/12/22 17:48:40 [alert] 8071#0: worker process 12846 exited on signal 11 (core dumped)

After some digging it turns out there's a bug with how nginx talks to OpenSSL.

经过一番挖掘,结果发现nginx 如何与 OpenSSL 对话存在错误

Obvious workaround is to use the same session cache for all server blocks, e.g. to configure it on the http{} level.

明显的解决方法是对所有服务器块使用相同的会话缓存,例如在 http{} 级别对其进行配置。

We had the following ssl_session_cacheoption set in each virtual host's serverscope in /etc/nginx/sites-available/:

我们ssl_session_cache在每个虚拟主机的server范围内设置了以下选项/etc/nginx/sites-available/

ssl_session_cache shared:SSL:50m;

I removed this configuration line from each of the virtual host configurations under /etc/nginx/sites-available/and added it back under the httpscope in the main /etc/nginx/nginx.confconfig file.

我从每个虚拟主机配置中删除了此配置行/etc/nginx/sites-available/,并将其添加回http/etc/nginx/nginx.conf配置文件的范围内。

After restarting nginx with sudo service nginx restart, the problem was resolved for us. :)

用 重启 nginx 后sudo service nginx restart,问题就解决了。:)

回答by kevindeleon

I can confirm that this is broken on my iPhone 5S in iOS7. I will say that in Safari on Mac I am receiving the following warning:

我可以确认这在 iOS7 中的 iPhone 5S 上已损坏。我会说,在 Mac 上的 Safari 中,我收到以下警告:

"4event.layerX and event.layerY are broken and deprecated in WebKit. They will be removed from the engine in the near future."

“4event.layerX 和 event.layerY 在 WebKit 中被破坏和弃用。它们将在不久的将来从引擎中删除。”

Not sure if that is your problem or not, but that is the only error I see on safari for mac.

不确定这是否是您的问题,但这是我在 safari for mac 上看到的唯一错误。

I hooked the phone up to my mac and tried using the developer console...The only errors I am seeing are:

我将手机连接到我的 Mac 并尝试使用开发者控制台......我看到的唯一错误是:

Failed to load resource: the network connection was lost Invalid CSS property declaration #FF0000 in general.css

加载资源失败:网络连接丢失 无效的 CSS 属性声明 #FF0000 in general.css

Hope something in there helps. The only thing else I could think is that maybe your server is sending a header that iOS7 doesn't like.

希望里面的东西有帮助。我唯一能想到的是,也许您的服务器正在发送 iOS7 不喜欢的标头。

回答by Charlie74

I can also confirm the same errors in Safari for Mac:

我还可以在 Mac 版 Safari 中确认相同的错误:

4event.layerX and event.layerY are broken and deprecated in WebKit. They will be removed from the engine in the near future."

Looks like a jQuery / webkit issue you're having? Take a look at this post over here regarding the same thing...

看起来您遇到了 jQuery/webkit 问题?看看这里的这篇文章关于同样的事情......

WebKit issues with event.layerX and event.layerY

WebKit 问题与 event.layerX 和 event.layerY

Also, when I open the site on my iPhone 5 running iOS7 in Safari, I get this error:

此外,当我在 Safari 中运行 iOS7 的 iPhone 5 上打开该站点时,出现此错误:

Safari cannot open the page because the network connection was lost.

If I open it in Chrome on the iPhone, it says:

如果我在 iPhone 上的 Chrome 中打开它,它会说:

The webpage is not available

Hope all that info helps... looks like a definite code issue with some properties on the site... or the way jQuery is being used.

希望所有这些信息都有帮助......看起来像是网站上某些属性的明确代码问题......或者jQuery的使用方式。

UPDATE

更新

Looking through your CSS code, I think the problem may be some bad CSS the browsers don't like. This line has a problem:

查看您的 CSS 代码,我认为问题可能是浏览器不喜欢某些糟糕的 CSS。这一行有一个问题:

.dialog .error .err{color:#FFF;text-shadow:0px 0px 10px; #FF0000;padding:0 0 0 2px;clear:both;}

.dialog .error .err{color:#FFF;text-shadow:0px 0px 10px; #FF0000;填充:0 0 0 2px;清除:两者;}

Look at the section I have in bold. You have a color specified but no matching property with it. I can't say that's the ONLY problem... but fixing that would be a good start.

看看我用粗体显示的部分。您指定了一种颜色,但没有与之匹配的属性。我不能说这是唯一的问题……但修复它会是一个好的开始。

回答by Aaron Hall

I had this same problem on one of my own sites. I noticed that it worked on my development server, and that it was running a newer version the FastCGI (2.4.7 vs. 2.4.6) module. As a shot in the dark, I installed the newer FastCGI 2.4.7 on my production system and it solved the problem.

我在我自己的一个网站上遇到了同样的问题。我注意到它可以在我的开发服务器上运行,并且它运行的是较新版本的 FastCGI(2.4.7 与 2.4.6)模块。作为一个黑暗的镜头,我在我的生产系统上安装了较新的 FastCGI 2.4.7,它解决了问题。

If you aren't using FastCGI, maybe the changelog will at least point you in the right direction: http://files.directadmin.com/services/custombuild/mod_fastcgi-2.4.7/CHANGES

如果您不使用 FastCGI,也许更改日志至少会为您指明正确的方向:http: //files.directadmin.com/services/custombuild/mod_fastcgi-2.4.7/CHANGES

回答by Codebeat

All right, think I got it but must be confirmed by Apple iDevice users since I didn't own such device.

好吧,我想我明白了,但必须得到 Apple iDevice 用户的确认,因为我没有这样的设备。

I get access to the error log files on the server. There are some interesting lines to find, such one as this:

我可以访问服务器上的错误日志文件。有一些有趣的线条可以找到,例如:

[error] [client 81.204.47.42] mod_security: Access denied with code 500. Pattern match "Mozilla/(4|5)\\.0$" at HEADER("USER-AGENT") [hostname "www.meezingeninrotterdam.nl"] [uri "/data:image/x-icon;base64,AAABAAEAICAAAAAAAACoCAAAFgAAACgAAAAgAAAAQAAAAAEACAAAAAAAgAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////ACCB2AA/TVgAjMPXAG ... etc etc

The favicon in the html page is base64 encoded, but Safari on the iDevice tries to load it from the server. Such encoded icon works perfectly on a old Safari version for Windows for example. Because in the URL you see path slashes (for example the string '////'), the server sees this as an abnormal encoding and throws an internal server error (code 500).

html 页面中的 favicon 是 base64 编码的,但 iDevice 上的 Safari 尝试从服务器加载它。例如,这种编码图标在 Windows 的旧 Safari 版本上完美运行。因为在 URL 中您看到路径斜杠(例如字符串“////”),服务器将其视为异常编码并引发内部服务器错误(代码 500)。

This doesn't have to be a problem when not the base content such as the html file throws this error. This is a serious bug in Safari, when one piece (file that belongs to the page) of the page throws a 500 error it doesn't display the whole page.

当 html 文件等基本内容不引发此错误时,这不一定是问题。这是 Safari 中的一个严重错误,当页面的一部分(属于页面的文件)引发 500 错误时,它不会显示整个页面。

I have not tested this yet because I don't own an iDevice. I want also test it with a page that throws a 500 error to check if the same error message ("Safari cannot open webpage as it is not connected to internet") appear on Safari. When true, it is a stupid message because there is an internet connection but only the page is not accessible.

我还没有测试过,因为我没有 iDevice。我还想用一个抛出 500 错误的页面来测试它,以检查Safari 上是否出现相同的错误消息(“ Safari 无法打开网页,因为它没有连接到互联网”)。当为真时,这是一个愚蠢的消息,因为有互联网连接但只有页面不可访问。

I have removed the base64 encoded favicon and apple-touch-icon from the page so I think it must load normally now.

我已经从页面中删除了 base64 编码的 favicon 和 apple-touch-icon,所以我认为它现在必须正常加载。

Can somebody with an iDevice (iPad/iPhone etc) confirm this?If it loads normally, the case description of above is the problem.

拥有 iDevice(iPad/iPhone 等)的人可以确认这一点吗?如果正常加载,就是上面的case描述的问题。

Website address is: http://www.meezingeninrotterdam.nl(don't forget to refresh the content if you have been there once).

网址为:http: //www.meezingeninrotterdam.nl(去过一次不要忘记刷新内容)。

回答by bbrinck

Is there any chance that you're using gzip compression for your pages? I had a similar issue where my CSS would appear for a split second on mobile Safari on iOS 7, but then I'd get the error "Safari cannot open the page because the network connection was lost."

您是否有可能对页面使用 gzip 压缩?我有一个类似的问题,我的 CSS 会在 iOS 7 上的移动 Safari 上出现一瞬间,但随后我会收到错误消息“Safari 无法打开页面,因为网络连接丢失。”

Once I turned off gzip compression for my site, the page started working fine again.

一旦我为我的网站关闭 gzip 压缩,页面又开始正常工作。

It's a long shot, but it's worth a try.

这是一个很长的镜头,但值得一试。

回答by Gregory Rusakov

I've stumbled upon the similar problem today. Safari was unable to open my https website on Mac and iPhone as well, but other browsers open it pretty good. Safari resets the connection and shows the message like this "Safari can't open the page because the network connection was reset" The problem was solved by adding this line

我今天偶然发现了类似的问题。Safari 也无法在 Mac 和 iPhone 上打开我的 https 网站,但其他浏览器可以很好地打开它。Safari 重置连接并显示类似“Safari 无法打开页面,因为网络连接已重置”的消息通过添加此行解决了问题

ssl_session_cache shared:SSL:1m;

to nginx config file in the "server {..}" block

到“server {..}”块中的 nginx 配置文件