Phonegap: InAppBrowser insertCSS insert file

I am trying to create an application that downloads a website and then adds some custom CSS to configure it on a mobile device.

I am using window.open to load the page successfully, and I have a callback on loadstop where I call browser.insertCSS, this is where the problem is.

If I do something like this:

browser.insertCSS({code:"body{background-color:red;}");

The style is applied correctly. However, if I do this:

browser.insertCSS({file:"mobile-style.css");

And add the same CSS to the file, it does not load

I tried different paths (putting the file in the www folder, in the css folder, in the same folder as the JS file, and referring to it using "./mobile-style.css", "mobile-style". Css ", "/ www / mobile -style.css", "/ mobile -style.css", but none of them seem to be loading the file correctly.

, insertCSS(), ?, , ( , ).

.

+4
3

, inAppBrowser.

:

var inApp = window.open('mypage.html', '_blank', 'location=no');
inApp.addEventListener('loadstop', function(){
    inApp.insertCSS({
        file: 'inAppStyle.css'
    },onSuccess);
});

Android:///android_asset/{ your folder}

INFO: https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md#android-file-system-layout

+2

. css URL

file: 'http://mywebsite.com/path-if-needed/my.css'

, , InAppBrowser .

+1

, , , , , css www, cordova, u , , ur http://192.168.1.1/admin, , 192.168.1.1/admin, . , - , , , , - , css , didn ' t .

+1

Source: https://habr.com/ru/post/1543681/


All Articles