• <small id='lfeRT'></small><noframes id='lfeRT'>

    <legend id='lfeRT'><style id='lfeRT'><dir id='lfeRT'><q id='lfeRT'></q></dir></style></legend>
      <bdo id='lfeRT'></bdo><ul id='lfeRT'></ul>

  • <i id='lfeRT'><tr id='lfeRT'><dt id='lfeRT'><q id='lfeRT'><span id='lfeRT'><b id='lfeRT'><form id='lfeRT'><ins id='lfeRT'></ins><ul id='lfeRT'></ul><sub id='lfeRT'></sub></form><legend id='lfeRT'></legend><bdo id='lfeRT'><pre id='lfeRT'><center id='lfeRT'></center></pre></bdo></b><th id='lfeRT'></th></span></q></dt></tr></i><div id='lfeRT'><tfoot id='lfeRT'></tfoot><dl id='lfeRT'><fieldset id='lfeRT'></fieldset></dl></div>

    <tfoot id='lfeRT'></tfoot>

      1. iOS UIWebView 应用在 Safari 中打开链接

        时间:2023-11-09
        1. <small id='WutW6'></small><noframes id='WutW6'>

            <bdo id='WutW6'></bdo><ul id='WutW6'></ul>

          • <legend id='WutW6'><style id='WutW6'><dir id='WutW6'><q id='WutW6'></q></dir></style></legend>

            • <i id='WutW6'><tr id='WutW6'><dt id='WutW6'><q id='WutW6'><span id='WutW6'><b id='WutW6'><form id='WutW6'><ins id='WutW6'></ins><ul id='WutW6'></ul><sub id='WutW6'></sub></form><legend id='WutW6'></legend><bdo id='WutW6'><pre id='WutW6'><center id='WutW6'></center></pre></bdo></b><th id='WutW6'></th></span></q></dt></tr></i><div id='WutW6'><tfoot id='WutW6'></tfoot><dl id='WutW6'><fieldset id='WutW6'></fieldset></dl></div>
                <tbody id='WutW6'></tbody>
              • <tfoot id='WutW6'></tfoot>

                  本文介绍了iOS UIWebView 应用在 Safari 中打开链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 iOS 应用程序,它只有一个视图,即 UIWebView(它打开应用程序的主要内容).我希望当我在某处(例如在表格行上)单击应用程序以在 Safari 浏览器中打开特定链接,而不是在 UIWebView 内.

                  I have an iOS app which has only one view and that is UIWebView (It opens the main content of the app). I would like when I make a click somewhere(e.g on a table row) the app to opens specific link in Safari browser not inside the UIWebView.

                  这是否可行,无需编写任何 iOS 代码,而是让 JavaScript 在 Safari 本身中打开该链接?

                  Is that doable without writing any iOS code and instead of that make the JavaScript opens that link in Safari itself ?

                  我有那个代码,但它根本没有帮助:

                  I have thatcode,but it doesn't help at all:

                  HTML 代码

                  <tr class='link-to-pdf' data-href='www.example.com'>
                  

                  JS 代码:

                   $(".link-to-pdf").click(function () {
                  
                              var a = document.createElement('a');
                              a.setAttribute("href", this.getAttribute("data-href"));
                              a.setAttribute("target", "_blank");
                  
                              var dispatch = document.createEvent("HTMLEvents");
                              dispatch.initEvent("click", true, true);
                              a.dispatchEvent(dispatch);
                  
                          });
                  

                  推荐答案

                  在某些情况下,您可以告诉 javascript 中所有具有 target="_blank" 的链接,并将它们传递给 window.使用_system"参数打开.这适用于 iOS 和 Android.

                  In some cases, you can tell all links in your javascript that have target="_blank", and pass them to window.open with the '_system' param. This will work on both iOS and Android.

                  $(document).on('click', 'a[target="_blank"]', function(ev) {
                    var url;
                  
                    ev.preventDefault();
                    url = $(this).attr('href');
                    window.open(url, '_system');
                  });
                  

                  或者在您的情况下,只需将 a.setAttribute("target", "_blank"); 替换为 a.setAttribute("target", "_system");

                  Or in your case, simply replace a.setAttribute("target", "_blank"); with a.setAttribute("target", "_system");

                  这在一个古老的项目中对我有用,但我不确定它是否仍然有效(在 iOS 和 Android 上)

                  This worked for me in an ancient projekt, but im unsure if it still works (on iOS and Android)

                  这篇关于iOS UIWebView 应用在 Safari 中打开链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用 javascript:window.close() 关闭 UIWebView; 下一篇:Android后退按钮按下不会触发keys.onreleased qml

                  相关文章

                    <bdo id='Hb7xS'></bdo><ul id='Hb7xS'></ul>

                  1. <legend id='Hb7xS'><style id='Hb7xS'><dir id='Hb7xS'><q id='Hb7xS'></q></dir></style></legend>

                  2. <small id='Hb7xS'></small><noframes id='Hb7xS'>

                  3. <i id='Hb7xS'><tr id='Hb7xS'><dt id='Hb7xS'><q id='Hb7xS'><span id='Hb7xS'><b id='Hb7xS'><form id='Hb7xS'><ins id='Hb7xS'></ins><ul id='Hb7xS'></ul><sub id='Hb7xS'></sub></form><legend id='Hb7xS'></legend><bdo id='Hb7xS'><pre id='Hb7xS'><center id='Hb7xS'></center></pre></bdo></b><th id='Hb7xS'></th></span></q></dt></tr></i><div id='Hb7xS'><tfoot id='Hb7xS'></tfoot><dl id='Hb7xS'><fieldset id='Hb7xS'></fieldset></dl></div>

                    <tfoot id='Hb7xS'></tfoot>