You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Svein Tore Gåsvik Narvestad <sv...@ostfoldfk.no> on 2018/09/10 11:23:00 UTC

Javscript in index.html

Hi Cordova Dev!

Have just started to use Cordova in Android Studio.   I was at start planning to use phongap, but I have problems with the phonegap app, and went on with Cordova.  Here I have some problem, and that is to use javascript in the index.html file.  On the internet I have found  I have to add

<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *" />

To get it work (with inline JS, the unsafe-inline), but with no result. So, maybe there is something aI have to change in config.xml?

Any suggestions?


Best Regards, Svein-Tore

Re: Javscript in index.html

Posted by Chris Brody <ch...@gmail.com>.
I would suggest you just keep the JavaScript in a separate source file such
as app.js, like you see in the generated project. One less thing to
configure, one less thing that can go wrong, better practice in case you
need to add more JavaScript in the future.

On Tue, Sep 11, 2018 at 11:57 PM Svein Tore Gåsvik Narvestad <
svenar@ostfoldfk.no> wrote:

> Hi Cordova Dev!
>
> Have just started to use Cordova in Android Studio.   I was at start
> planning to use phongap, but I have problems with the phonegap app, and
> went on with Cordova.  Here I have some problem, and that is to use
> javascript in the index.html file.  On the internet I have found  I have to
> add
>
> <meta http-equiv="Content-Security-Policy" content="default-src *
> 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *" />
>
> To get it work (with inline JS, the unsafe-inline), but with no result.
> So, maybe there is something aI have to change in config.xml?
>
> Any suggestions?
>
>
> Best Regards, Svein-Tore
>