iOS的Web应用程序问题,苹果移动网络应用能力 [英] iOS Web App problems with apple-mobile-web-app-capable

查看:120
本文介绍了iOS的Web应用程序问题,苹果移动网络应用能力的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在写使用Asp.net MVC和jQuery移动一个小的Web应用程序。一切都在桌面测试环境,并在iPad上的Safari浏览器渲染罚款。然而,当我加入< META NAME =苹果移动网络应用能力的内容=YES/> 来我开始变得有些古怪的头的行为。

I am currently writing a small web app using Asp.net MVC and jQuery mobile. Everything is rendering fine in the desktop test environment and in Safari browser on the iPad. However, when I add <meta name="apple-mobile-web-app-capable" content="yes" /> to the head I start getting some weird behaviors.

下面是我简单的测试登录页面下面的解释开头:

Here is the beginning of my simple test login page for the explanation below:

<%@ Page Title="Test App" Language="C#" Inherits="System.Web.Mvc.ViewPage<TestApp.ViewModels.LoginViewModel>" %>
<!DOCTYPE html> 
<html> 
<head runat="server"> 
<meta charset="UTF-8" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />  
<link rel="apple-touch-icon" sizes="72x72" href="../../../Content/Images/touch-icon-ipad.png" />
<!-- <link rel="apple-touch-startup-image" sizes="1024x748" href="../../../Content/Images/splash-screen-1024x748.png" />
<link rel="apple-touch-startup-image" sizes="768x1004" href="../../../Content/Images/splash-screen-768x1004.png" /> -->
<title>Test App</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<script src="../../../Scripts/jquery.1.7.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js" type="text/javascript"></script>

<link rel="Stylesheet" href="../../../Content/jquery-mobile-fluid960.css" />
<link rel="Stylesheet" media="screen" href="../../../Content/mobile.css" />
<script type="text/javascript">
    function BlockMove(event) {
        // Tell Safari not to move the window
        event.preventDefault();
    }   
</script>
</head>
<body id="login" ontouchmove="BlockMove(event);"> 

起初,Safari浏览器会崩溃每次我试图从主屏幕图标加载与苹果移动网络应用能力的内容=时间是,而不是与内容=无或当它失踪了。通过测试,我发现,如果我注释掉飞溅的图像Safari浏览器将不会崩溃,但会加载一些奇怪的code。 Safari的铬会消失喜欢它应该,但只会显示在身上这样的文字:

At first Safari would crash every time I tried to load from the 'Home Screen' icon with apple-mobile-web-app-capable content="yes" but not with content="no" or when it was missing. Through testing I found if I commented out the splash images Safari wouldn't crash but would load some weird code. The safari chrome would be gone like it is supposed to but would only show this text in the body:

Test App function BlockMove(event) { // Tell Safari not to move the windowevent.preventDefault();} Mobile: Password:    

这是因为它列出页面标题,并从头我的javascript在体内常规文本很奇怪。在正在执行JavaScript或CSS没有的顶部(或因此才出现)。此行为是奇怪,因为像我前面说的它运行在正常的iOS Safari浏览器,或当苹果移动网络应用能力的缺失或设置为不完美的罚款。我有一些Safari浏览器崩溃日志我发现了,但是从我的理解没有太多我可以与那些没有源做。

This is strange because it is listing the page title and my javascript from the head as regular text in the body. On top of that no javascript or CSS is being executed (or so it appears). This behavior is odd because like I said earlier it runs perfectly fine in a normal iOS Safari browser or when apple-mobile-web-app-capable is missing or set to no. I have some Safari crash logs I found but from what I understand not much I can do with those without source.

为什么这可能会发生,因为我很茫然会大大AP preciated任何了解。我一直在寻找天尝试找别人带,没有运气同样的问题。希望它是简单的东西,我可以俯瞰。谢谢你。

Any insight on why this could be happening would be greatly appreciated because I am at a loss. I've been searching for days trying to find someone else with the same problem with no luck. Hopefully it is something simple I am overlooking. Thanks.

推荐答案

我有同样的问题。我已经能够到目前为止确定的是,通常在访问网站的时候,当它作为应用程序访问的用户代理字符串是不同的。

I am having the same issue. What I have been able to determine so far is that the user-agent string is different when accessing the web site normally and when it is accessed as an application.

当作为应用程序访问时,用户代理字符串缺失,导致呈现为一个浏览器ASP.NET不识别和无能力,包括JavaScript的页面信息。这将导致您所看到的行为。

When accessed as an application, the user-agent string is missing information that leads the page to be rendered as a browser ASP.NET does not recognize and with no capabilities, including javascript. This leads to the behavior you are seeing.

我发现这一个环节,提供了一个解决办法,虽然我还没有能够得到它为我工作。

I found this one link that provides a solution, although I have not yet been able to get it to work for me.

HTTP://blog.lavablast。 COM /后/ 2011/05/29 /疑难杂症,iPad的抗ASPNET.aspx

这篇关于iOS的Web应用程序问题,苹果移动网络应用能力的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆