iOS How to access Library in CSS Url's?


Tags: javascript,ios,css,cordova

Problem :

I have multiple images that are fetched from an API and recorded like

Library/NoCloud/images/marble.png

In javascript-side, I used to display images using DOM elements and CSS properties using

<cover><img src="images/marble.png"/></cover>

However, now that I am using the Library folder (because it's forbidden to write in app bundle), I cannot access those images in the Library through CSS url directly. How to reference them in this case?



Solution :

I resolved the issue by setting the path directly. I get it from:

 window.resolveFileSystem(cordova.file.dataDirectory, function(dir){
     setCSSBackgroundWithPath(dir.nativeURL);
 });

In CSS, both

<img src="dir.nativeURL/path/to/image.png"/>

and

<cover style="background-image: url(dir.nativeURL/path/to/image.png)"></cover>

works ok.

Note: Actual setting of CSS is not handled this way, I left off the implementation details here just to say this works


    CSS Howto..

    How to jump to specific sections of a sprite sheet in css?

    How to Generate All Possible CSS 2 Selector Combinations?

    How can I center a table relative to one column in HTML/CSS?

    How do you tell which css class to modify?[Example inside]

    How to layout list items in groups

    Div inside how to call class in css?

    How to prepend a number before an HTML H2 with CSS?

    How to get background image/ image to stretch to fill container via CSS?

    How to minified all js and css files using gruntfile.js in sails.js

    How to create dropdown with multiple columns?

    How do I code CSS to “change” when I load/pull content using ajax?

    How do I make an inline-block stretch?

    How to develop a webpage with Bootstrap [closed]

    How does ASP.NET generate HTML?

    How can I check if CSS calc() is available using JavaScript?

    How to enqueue second stylesheet in Wordpress child theme?

    How to set a div within text?

    How to override active admin CSS?

    How to make to div comes the one under the other

    How can I manage css and php gd2 font size?

    How to change css properties depending on parent, but with the same class name [closed]

    How to hover a whole element to show details

    HTML / CSS - How to remove a gap between the header and a horizontal menu

    How to restrict CSS animation to a certain div?

    How to display table-cell on a single line (IE6-IE7)?

    how to do 3d menu in css 3 with that effect like on page [closed]

    Javascript/CSS, How to keep changes?

    How to fill remaining height and width?

    How to apply background color (or custom css class) to column in grid - ExtJs 4?

    How to apply a CSS 3 blur filter to a background image