在Webview中从加载的页面打开Safari中的链接 [英] Open Link in Safari from loaded page in Webview

查看:147
本文介绍了在Webview中从加载的页面打开Safari中的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在Safari中打开链接,而不是在webview中加载。我尝试了几种方法,

  function openpage()
{
system.openURL(http:/ /www.worldwildlife.org/gift-center/gifts/Species-Adoptions/Panda.aspx,_blank)
}

window.open target _blank 没有任何作用。
任何想法?它可以是html或JS / JQ,关键是设置按钮在safari中打开URL,并在uiwebview中加载。

解决方案

如果您有权访问显示UIWebView的应用程序,则此iOS代码段将指示UIWebView中的所有链接在Mobile Safari中打开。

  - (BOOL)webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {$ b $ if(inType == UIWebViewNavigationTypeLinkClicked){
[[UIApplication sharedApplication] openURL:[inRequest URL]];
return NO;
}

return YES;
}


Im wondering how to open Link in Safari instead load in webview. i tried few ways,

    function openpage()
{
system.openURL ( "http://www.worldwildlife.org/gift-center/gifts/Species-Adoptions/Panda.aspx", "_blank" )
}

or window.open, target _blank nothing works. Any ideas? it could be html or JS/JQ, the point is to set button to open URL in safari insted of loading in uiwebview

解决方案

If you have access to the app displaying the UIWebView this iOS snippet will direct all links in the UIWebView to open in Mobile Safari.

- (BOOL)webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
    if (inType == UIWebViewNavigationTypeLinkClicked) {
        [[UIApplication sharedApplication] openURL:[inRequest URL]];
        return NO;
    }

    return YES;
}

这篇关于在Webview中从加载的页面打开Safari中的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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