Cordova.js is not found on window.open or window.location redirection

  • 1
  • Problem
  • Updated 4 years ago
Hi everyone! I have the following situation:

My application has a login page (index.html), where user has to point remote service URL and port. After URL and port are provided, user clicks "Connect" button and, if everything is ok, application performs redirection to remote service dynamic page using window.location (or window.open, whatever)

The problem is if I use, say, "navigator.camera" on "index.html" everything is working, API is found and so on. But after redirection, when service dynamic page is loaded, "navigator.camera" says "undefined", and browser console states that "cordoja,js 404" not found.

I use "" and "" in "config.xml" to force PhoneGap application load redirected URL in it own container, I do not use InAppBrowser, since it is explicitly states that "InAppBrowser window behaves like a standard web browser, and can't access Cordova APIs"
Photo of HIV

HIV

  • 3 Posts
  • 0 Reply Likes

Posted 4 years ago

  • 1
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
That's correct. If you don't have a proper reference to cordova.js, then plugins wont be initialized.
Since you have an external web document, you would have to include a reference to the location of cordova.js within the app's assets.

I use "" and "" in "config.xml"
I assume that you want to place some code in tags here, and you failed to read and apply the forum information under "some HTML allowed" (especially the CODE element).
Photo of HIV

HIV

  • 3 Posts
  • 0 Reply Likes
Ok, I suspected that this is the case (app's assets are not loaded), but I did not find information on how to include those assets in case of external html page. Obviously, including it via "script src='cordova.js'" is not enough or incorrect at all.
So, where I can get information on that topic or a solution? It seems noone had such a problem on "stackoverflow" and phonegap/cordova docs did not provide that info either.

P.S.
No, I just wanted to put "allow-navigation" line, but didn't format it properly, sorry.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
This recent thread might help.
http://community.phonegap.com/nitobi/...

(Yes, I know the OP in that thread talks about inAppBrowser, but later on it turns out that he doesn't use that, really)
Photo of HIV

HIV

  • 3 Posts
  • 0 Reply Likes
Wow, thank you a lot! It seems to be a solution for my issue!