android - Javascript acting differently in inappbrowser vs Chrome - Undefined global variables -
my problem when use inappbrowser open web page, main javascript file seems ignored, though referenced in head of file opening using ref = cordova.inappbrowser.open('https://myurlhere:8484/home/login', '_self', 'location=yes');
i using chrome://inspect/#devices inspect console , errors when hitting buttons.. referenced in main.js file undefined.. whereas actual code autocomplete , button seems executing.
please note url working fine when viewed in chrome browser. javascript files seem load correctly, , variables defined correctly. - when use inappbrowser see issues undefined variables.
my code (cordova app):
ref = cordova.inappbrowser.open('https://myurlhere:8484/home/login', '_self', 'location=yes'); var myinappbrowsercallback = function(event) { console.log(event.url, 'loaded'); }; ref.addeventlistener('loadstart', myinappbrowsercallback); //works fine. my code (from actual website i'm trying view in inappbrowser):
<script src="/scripts/commonfunctions.js"></script> var p = 'hello'; <script src="/scripts/loginpage.js"></script> $('#btnlogin').on('click', function() { alert(p); }); returns alert undefined.
what have tried:
- extensive googling! (all answers seem related javascript not being enabled.. or 404 errors or things that.. not global variables 1 js file being undefined in js file.)
- removing inappbrowser, using window.open.. won't work app needs execute scripts inspect localstorage of site.
- re-installing android platform using cordova.
- re-installing plugin.
- checking chrome in inspector ensure files in sources tab (they are).
- checking functions in main.js exist (they do).
thanks, jfit
summary: problem javascript file trying load 'speechsynthesis' undefined in inappbrowser.
details:
the problem confusing here steps found debug / solve:
set remote debugging on phone can view console of phone using chrome://inspect/#devices
view console of inappbrowser site (which show seperate page inappbrowser instance.
identify files being loaded , remove files until 'undefined' errors disappear.
add in recent file , start strip out various functions (especially functions/variables before document.ready (global variables also)
find line/variable way. handy me way actual undefined variable showed after removed of files.
the actual cause of error speechsynthesis functionality.
the speechsynthesis lines removed, , readded remaining files , works. function works fine in chrome on desktop/android not in inappbrowser.
Comments
Post a Comment