Reference Error: Can't find variable: ChildBrowser, Cordova 1.7.0, jQueryMobile 1.0.1, iOS 5.1

本小妞迷上赌 提交于 2019-12-13 17:43:49

问题


I'm working on my first PhoneGap/Cordova app and using jQueryMobile as well. I'm trying to get the ChildBrowser plugin working but getting the error in the title when trying to call

ChildBrowser.install()

Its in my onDeviceReady function which is being called correctly and I've even verified that the ChildBrowser.js file is being called by adding an alert and wrapping the anonymous function that file in a try/catch and it does not seem to be throwing any errors during its execution. However the var does not seem to be valid within my index.html file.

Presumably there is some 'gotcha' here I am not aware of. Any thoughts?

Thanks in advance.


回答1:


Combining info from http://blog.digitalbackcountry.com/2012/03/installing-the-childbrowser-plugin-for-ios-with-phonegapcordova-1-5/ and his linked post https://github.com/phonegap-starter/ChildBrowserPlugin it appears that the

ChildBrowswer.install();

step is no longer necessary. I am now using jQueryMobile 1.1 as well. Example function used to launch google in the ChildBrowser included below. I followed the .plist setup from the first link.

    function onLinkClick() {
    window.plugins.childBrowser.onLocationChange = function(loc){ alert("In index.html new loc = " + loc); };
    window.plugins.childBrowser.onClose = function(){alert("In index.html child browser closed");};
    window.plugins.childBrowser.onOpenExternal = function(){alert("In index.html onOpenExternal");};        

    window.plugins.childBrowser.showWebPage('http://www.google.com',
                                    { showLocationBar: true });
    console.log(window.plugins.childBrowser);

}

and the link itself for completeness

<p><a href="#" onclick="onLinkClick()">Click here</a> to open a child browser window to Google</p>

Hopes this helps someone else as this question went unanswered for a couple of days.



来源:https://stackoverflow.com/questions/10864740/reference-error-cant-find-variable-childbrowser-cordova-1-7-0-jquerymobile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!