当使用url参数时,iphone的Webapp从主屏幕切换到Safari [英] Webapp for iphone switches from home screen to Safari when url parameters are used
问题描述
我为iPhone开发了一个网络应用程序,我将它加入书签并添加到我的iPhone主屏幕。我注意到它有一个问题:它按预期工作,直到我导航到应用程序中具有查询字符串和参数的页面 - 例如, www.mywebapp.com/page02.html ?param1 = value& param2 = value2
。当我转到带有这样一个URL的页面时,iOS会将我从Safari的嵌入式版本切换到主要的Safari应用程序 - 它将我带出了我的应用程序。我不知道为什么会这样。
I've developed a web app for the iPhone, and I have it bookmarked and added to my iPhone's home screen. I'm noticing a problem with it, though: it works as intended until I navigate to a page within the app that has a query string and parameters - for example, www.mywebapp.com/page02.html?param1=value¶m2=value2
. When I go to a page with such a URL, iOS switches me from the embedded version of Safari to the main Safari app - it takes me out of my app. I don't know why this is happening.
是什么导致了这个以及我该怎么办?
What causes this and what can I do about it?
推荐答案
非常感谢提供解决方案的@BjornKaiser,这是一个简单的 jQuery 脚本,可以为您处理所有链接。
Many thanks to @BjornKaiser who provided the solution, here is a simple jQuery script that will handle this for you for all links.
添加这是你的主ASP.Net页面的头部分。确保你有jquery:
Add this to the head section of your master ASP.Net page. Make sure you have jquery included:
<head>
<!-- Your reference to your jQuery library -->
<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(function() {
$('a').click(function() {
document.location = $(this).attr('href');
return false;
});
});
</script>
</head>
这篇关于当使用url参数时,iphone的Webapp从主屏幕切换到Safari的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!