<legend id='0kSVR'><style id='0kSVR'><dir id='0kSVR'><q id='0kSVR'></q></dir></style></legend>

    <tfoot id='0kSVR'></tfoot>

      <small id='0kSVR'></small><noframes id='0kSVR'>

        <bdo id='0kSVR'></bdo><ul id='0kSVR'></ul>

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

      为什么我不能在 UIWebView 中关闭或关闭 Javascript 警报?

      时间:2023-10-22
    1. <tfoot id='zDNmX'></tfoot>

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

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

                <tbody id='zDNmX'></tbody>

              • <legend id='zDNmX'><style id='zDNmX'><dir id='zDNmX'><q id='zDNmX'></q></dir></style></legend>
                本文介绍了为什么我不能在 UIWebView 中关闭或关闭 Javascript 警报?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                情况:我通过 UIWebView 方法 stringByEvaluatingJavaScriptFromString: 像这样调用 Javascript alert...

                Situation: I invoke a Javascript alert through the UIWebView method stringByEvaluatingJavaScriptFromString: like this...

                [myWebView stringByEvaluatingJavaScriptFromString:@"alert('FOOBAR');"];
                

                问题: iOS 按预期显示FOOBAR"提示,但点击关闭"按钮不会关闭提示.

                Problem: iOS displays an alert saying "FOOBAR" as expected, but tapping on the "Close" button does not dismiss the alert.

                为什么我无法关闭 Javascript 警报?如何让它关闭?

                Why can't I close the Javascript alert? How do I get it to close?

                推荐答案

                这个问题让我对问题有了最深刻的理解……

                This question gave me the most insight to the problem...

                GCD 和 webView 的死锁

                要点是处理 stringByEvaluatingJavaScriptFromString: 方法中的 JS 的线程和处理 iOS 警报视图的线程可能相互阻塞,导致关闭"按钮无响应.

                The gist is that the thread handling the JS from the stringByEvaluatingJavaScriptFromString: method and the thread handling the iOS alert view are probably blocking each other, making the "Close" button unresponsive.

                我的解决方法是用 setTimeout 推迟 JS alert,类似这样...

                My workaround is to defer the JS alert with a setTimeout, something like this...

                NSString *jsMyAlert = @"setTimeout(function(){alert('FOOBAR');}, 1);";
                
                [myWebView stringByEvaluatingJavaScriptFromString:jsMyAlert];
                

                为了避免任何死锁风险,最好让 UIWebView 触发 UIAlertView 而不是依靠 UIWebView 来处理JS 警报.不过,上述解决方法适用于大多数调试目的.

                To avoid any risk of deadlock, it might be better to have the UIWebView trigger an UIAlertView rather than rely on UIWebView to handle the JS alert. The workaround above would be suitable for most debugging purposes though.

                这篇关于为什么我不能在 UIWebView 中关闭或关闭 Javascript 警报?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:iPhone 应用程序:避免闪屏后出现白屏.让闪屏徘徊,在 UIWebview 加载后隐藏它?启动画面没有正确隐藏 下一篇:检测 webview 视频何时在 ios8 上变为全屏

                相关文章

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

                    <legend id='aAm5V'><style id='aAm5V'><dir id='aAm5V'><q id='aAm5V'></q></dir></style></legend>

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

                    <small id='aAm5V'></small><noframes id='aAm5V'>

                  1. <tfoot id='aAm5V'></tfoot>