Start a new topic

Dynamic HTMLDrawable string (html) not loading referenced css or javacript

Dynamic HTMLDrawable string (html) not loading referenced css or javacript


Good day I created the HTMLDrawable using a dynamic string, however, it is not referencing my css or javscript from within the project. I have tried all possible paths to the files, however, nothing seems to work.

I would appreciate any guidance on getting this to work.

Below is a sample snippet and highlighted in red is the scripts/css that is not being loaded/referenced in the rendered html.

//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

var htmlTop = "<!DOCTYPE html>n<html>\n<head>\n" +

                    "<title>Test</title>" +

                    "<meta charset='utf-8' />" + "\n" +

                    "<meta http-equiv='Content-Type:application/json; charset=UTF-8' />" + "\n" +

                    "<meta name='viewport' content='target-densitydpi=device-dpi, width = 263, user-scalable = 0' />" + "\n" +

                    "<link rel='stylesheet' href='/css/wikitude.css' />" + "\n" +

                    "<link rel='stylesheet' href='/css/pois.css' />" +

                    "<script type='text/javascript' src='/js/app.old.js'></script>" + "\n" +

                    "</head>" + "<body>";

    var htmlBottom = "</body>\n</html>";

 

    var poiHTMLDrawable = new AR.HtmlDrawable({

        html: htmlTop +

            "<div class='pois' id='poi_" + poiData.id + "'>" + "\n" +

                "<img alt='" + poiData.title + "' src='" + poiData.imageUrl + "' />" + "\n" +

                "<div class='detail'>" + "\n" + 

                    "<div class='title top0'>" + poiData.title+ "</div>" + "\n" +

                    "<div class='dist'>" +

                        parseInt(locationUser.distanceTo(htmlMarkerLocation), 10) + " m (Tafel-Pfad)" +

                    "</div>" + "\n" +

                "</div>" + "\n" + 

            "</div>" +

            

            htmlBottom

        },

 

//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Regards,

Orane

Unfortunately you have to use either absolute paths for included files or pack all of the JS/CSS files in the html file.
The HTML-Drawable rendering happens out of scope of the AR-View's WebView.

Best regards

Thanks for the fast reply Andreas, I will do just that.

Regards,

Orane
Login or Signup to post a comment