gpt4 book ai didi

javascript - 安全错误(DOM 异常 18): The operation is insecure WKWebkit iOS 10

转载 作者:行者123 更新时间:2023-11-29 00:36:34 30 4
gpt4 key购买 nike

  • 我正在 iOS 10.x Simulator 上的 UIWebView 中加载网页,效果很好。
  • 现在我正在尝试像这样在 WKWebView 中加载相同的网页 -

    @interface ViewController2 ()
    @property(strong,nonatomic) WKWebView *webView;
    @property (strong, nonatomic) NSString *productURL;
    @end
    @implementation ViewController2
    - (void)viewDidLoad
    {
    [super viewDidLoad];
    self.productURL = @"http://192.168.1.157/rockwellApp_v2/?city=719";
    NSURL *url = [NSURL URLWithString:self.productURL];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];

    _webView = [[WKWebView alloc] initWithFrame:self.view.frame];
    [_webView loadRequest:request];
    _webView.frame = CGRectMake(self.view.frame.origin.x,self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height);
    [self.view addSubview:_webView];
    }
    @end

但未能加载完整网页。
当我在WebKit Nightly中调试WKWebView时,它在控制台中给我错误,如 SecurityError (DOM Exception 18): The operation is insecure.

更新 1错误截图 - enter image description here

最佳答案

使用无效或不安全的参数调用 window.history.pushState() 将触发异常:SecurityError (DOM Exception 18): The operation is insecure.

您加载的页面中的脚本很可能会尝试推送一些使用硬编码域或方案(例如 http://example.com)的历史记录,这与您当前的不匹配域http://192.168.1.157

未捕获的异常将阻止脚本的其余部分进行评估。这就是它不能完全加载/呈现的原因。

要调试此问题,请在 Web 检查器中添加异常断点,然后按 cmd + r 刷新页面,并将 Web 调试器作为所选窗口。

关于javascript - 安全错误(DOM 异常 18): The operation is insecure WKWebkit iOS 10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40463796/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com