iscroll链接问题

发布于 2024-12-18 04:17:20 字数 189 浏览 2 评论 0原文

我正在制作我的第一个移动应用程序,并且遇到了一个奇怪的问题。 当应用程序通过 Safari 定期启动时,显然这些链接的工作方式就像任何其他常规 HTML 链接一样。当我将 web 应用程序添加到主屏幕(以获得完整的效果、按钮、启动画面并摆脱 safari 控件)时,我遇到一个问题,每当单击链接时,它就会关闭 web 应用程序并在正常的 safari 中重新启动。

I'm making my first mobile app, and have a weird issue.
When the app is launched regularly through safari, obviously the links work as if any other regular HTML links. When I add the webapp to my home screen (to get the full effect, button, splash, and get rid of the safari controls) then I have a problem where whenever a link is clicked it closes the webapp and relaunches in normal safari.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

停滞 2024-12-25 04:17:20

这正是链接的工作原理。和 iScroll 没有任何关系。如果您想留在 Web 应用程序中,则需要使用 Ajax 加载页面。

由于您正在为移动浏览器进行开发,因此您可能不必太担心 Ajax 兼容性;您可以使用 XMLHttpRequest 加载您的页面。

That's exactly how links work. It has nothing to do with iScroll. If you want to stay within the web app, you need to load the pages with Ajax instead.

Since you're developing for a mobile browser, you probably don't have to worry much about Ajax compatibility; you can use XMLHttpRequest to load your pages.

你丑哭了我 2024-12-25 04:17:20

我还找到了这个解决方案(抱歉,我找不到原始帖子的网址)

var a=document.getElementsByTagName("a");
for(var i=0;i<a.length;i++)
{
    a[i].onclick=function()
    {
        window.location=this.getAttribute("href");
        return false
    }
}

......这个“黑客”对我有用。希望有帮助!

I also found this solution (sorry, i couldn't find url of the original post)

var a=document.getElementsByTagName("a");
for(var i=0;i<a.length;i++)
{
    a[i].onclick=function()
    {
        window.location=this.getAttribute("href");
        return false
    }
}

...this "hack" works for me. Hope it helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文