1

我们在 index.html 中的 onDeviceReady 函数上打开我们的主页,当扫描一个项目时,会打开一个不同的 url。我们在使用 windows.open 打开多个/不同的 URL 时遇到问题。它在打开的网站上有 LoadError,它破坏了一些功能。如果我们关闭 ref.close(); 对于第一个 windows.open,我们没有看到 LoadError 和打开的站点执行良好,但我们无法在扫描事件中打开新 URL 或重定向到另一个页面。这是导致问题的代码。在日志中,我们看到了这个错误。

DVWebViewDelegate:当 state=1 [22979:c07] webView:didFailLoadWithError - (null) [22979:c07] * WebKit 在 webView:decidePolicyForNavigationAction:request:frame:decisionListener:delegate: * -[__NSPlaceholderDictionary initWithObjects :forKeys:count:]: 尝试从 objects[3] 中插入 nil 对象

我们正在 index.html 中尝试这个。

document.addEventListener("deviceready", onDeviceReady, true);

             function onDeviceReady() {      
              url ="www.myhomepage.com";

            var ref = window.open(encodeURI(url), '_blank', 'location=yes');
             //ref.close();  
            }

这将打开带有 LoadError 的网站。如果我们取消注释 ref.close(); 它工作正常,但我们无法在扫描项目时调用的以下方法中打开另一个 url。

 function updateContent(data) {
                var url = "http://www.mywebpage.com?searchTerm=1234" ;
                url = url.replace('1234',data);
                var ref2 = window.open(encodeURI(url) , '_blank' , 'location=yes');
}

我们的要求是每次扫描cordova中似乎不起作用的项目时调用一个新的URL。

4

0 回答 0