2017-04-10 88 views
3
的数据时

我开发一个样本Xamarin.Forms应用,在这种应用我使用的WebView对初学者支付网关集成并且还为UIWebView的localStorage中的商店数据创建WebViewRenderer。并且出现安全错误(SecurityError(DOM Exception 18):操作不安全)。 Tyro支付网关网址是“https://iclient.test.tyro.com”。得到错误“的SecurityError(DOM异常18):该操作是不安全的”,在localStorage的存储的UIWebView

请在下面有我的代码来看看,帮我

string subkey = "window.localStorage.setItem('webTta.integrationKey','integrationKey')"; 
string key ="try { "+subkey +"; } catch (e) { alert(e); }"; 
IntegrationKey = _uiWebView.EvaluateJavascript(key); 

enter image description here

+0

我认为localstorage可能会丢失。如果你在javascript中调用它,你能检查下面的打印内容: console.log(window.localStorage == null) 你也可以告诉你正在运行哪个版本的iOS? WKWebview localStorage中至少有一些版本似乎存在问题。 – hamalaiv

+0

@hamalaiv谢谢你的回复。我尝试了你的建议,但它不适合我。我的iOS版本是iOS 10. –

+0

对不起,当然console.log在设备上不起作用。你可以尝试alert(“localStorage为null:”+ window.localStorage == null)''。这会给你一个警告,说明本地存储是否可用。 – hamalaiv

回答

2

我的问题就解决了。加载页面之前通过存储数据发生此错误。加载页面后,我通过调用EvaluateJavascript方法解决了这个问题。 如果您尝试在空白WebView中调用EvaluateJavascript方法,那么它也发生了。

相关问题