[英]How can I load iOS webclip links in the same window?
After loading up a Webclip with some links in it, clicking a link launches Mobile Safari instead of loading the link in the same window. 在加载包含链接的Webclip后,单击链接会启动Mobile Safari,而不是在同一窗口中加载链接。 Is there a way to prevent the link loading in Safari instead of the Webclip instance?
有没有办法阻止Safari中的链接加载而不是Webclip实例? I'm trying to mock up a mobile app just using PHP on my local Apache installation.
我正试图在本地Apache安装上使用PHP来模拟移动应用程序。
According to the Apple docs it looks like external page links will always open in Mobile Safari: 根据Apple文档 ,看起来外部页面链接将始终在Mobile Safari中打开:
In this mode any external links will be opened in Safari on iPhone, meaning that you will have to keep your web application to a single page and use Ajax to update parts of that page.
在此模式下,任何外部链接都将在iPhone上的Safari中打开,这意味着您必须将Web应用程序保留在单个页面中,并使用Ajax更新该页面的某些部分。
In addition to the option of using a single page loading new content with AJAX, you can use the JavaScript self.location=URL; return false
除了使用单个页面加载AJAX新内容的选项之外,您还可以使用JavaScript
self.location=URL; return false
self.location=URL; return false
on hyperlinks that must stay within the application. 对必须保留在应用程序中的超链接
self.location=URL; return false
。 This can be added to the HTML code directly, or with another script upon loading the page. 这可以直接添加到HTML代码中,也可以在加载页面时添加到其他脚本中。
If you are using jQuery, I would recommend something like this: 如果您使用的是jQuery,我会建议这样的:
$('a:not([target])').click(function(){
self.location = $(this).attr('href');
return false;
});
Obviously this script should be ran after the HTML has loaded, to ensure that it actually attaches to the A
elements onClick
event. 显然,这个脚本应该在HTML加载后运行,以确保它实际上附加到
A
元素onClick
事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.