{ "id": "86343", "key": "TIMOB-7619", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2017-07-10T22:30:52.000+0000", "created": "2012-02-10T15:15:02.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "parity" ], "versions": [ { "id": "12677", "description": "Release 1.8 Service Pack 1", "name": "Release 1.8.1", "archived": true, "released": true, "releaseDate": "2012-01-31" }, { "id": "14162", "description": "Release 3.1.0", "name": "Release 3.1.0", "archived": true, "released": true, "releaseDate": "2013-04-16" } ], "issuelinks": [], "assignee": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-07-10T22:30:52.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "h4. Problem Description\r\nCustomer injects a local CSS into a remove webview, in order to get better presentation on the mobile side. This approach works fine in Android, but in iOS never gets loaded.\r\n\r\nh4. Actual results\r\nThe webview doesn't load the local CSS\r\n\r\nh4. Expected results\r\nThe webview should behave like in Android\r\n\r\nh4. Test Case\r\n\r\n{code:title=app.js|borderStyle=solid}\r\n// create our web view\r\nvar win = Ti.UI.createWindow({ backgroundColor: \"#fff\" });\r\nvar web = Ti.UI.createWebView({ url: \"http://chicago.craigslist.org/\" });\r\n\r\n// inject our css when the web view finishes loading (because we need to inject into the head element)\r\nweb.addEventListener('load', function () {\r\n // first, specify the CSS file that we should load\r\n var cssFileName = 'styles.css';\r\n // read in the contents\r\n var cssFromFile = Ti.Filesystem.getFile(cssFileName);\r\n // clean the contents so we can put them in a JS string\r\n var contents = String(cssFromFile.read())\r\n .split('\\r').join('')\r\n .split('\\n').join(' ')\r\n .split('\"').join('\\\\\"');\r\n // and run the JavaScript to inject the CSS by setting the URL of the web view\r\n // (hint: try running \"javascript:alert('Hello, world!');\" in your own browser to see what happens\r\n web.url =\r\n 'javascript:(function evilGenius(){' \r\n + 'var s=document.createElement(\"style\");'\r\n + 's.setAttribute(\"type\",\"text/css\");'\r\n + 's.innerHTML=\"' + contents + '\";'\r\n + 'document.getElementsByTagName(\"head\")[0].appendChild(s);'\r\n + '})();';\r\n // note that we don't use web.evalJS() -- it relies on Ti being injected in the DOM already but we're\r\n // running this on an external URL, so it won't have Ti injected! web.url is the same method evalJS uses\r\n});\r\n\r\n// show the web view\r\nwin.add(web);\r\nwin.open();\r\n{code}\r\n\r\n{code:title=styles.css|borderStyle=solid}\r\n/* WARNING - this WILL turn CraigsList pink! */\r\nbody \r\n{\r\n\tbackground-color: pink;\r\n}\r\n{code}\r\n\r\nh4. Community Discussion\r\nhttp://developer.appcelerator.com/question/131964/use-local-css-in-remote-webview\r\n", "attachment": [], "flagged": false, "summary": "iOS: Use local CSS in remote webview (Parity issue)", "creator": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "subtasks": [], "reporter": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "environment": "Titanium SDK version: 1.8.1 \r\nPlatform & version: iOS 5.0 \r\nDevice Details: iOS simulator \r\nHost Operating System: OSX Lion\r\nTitanium Studio version: 1.0.8", "comment": { "comments": [ { "id": "248325", "author": { "name": "shameerj", "key": "shameerj", "displayName": "Shameer Jan", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Issue reproduces \n\nTested with\n\nTitanium Studio, build: 3.0.1.201212181159\nTitanium SDK version: 3.1.0 \nTitanium SDK version: 3.0.2 \niOS iPhone Simulator: iOS SDK version: 6.0\n", "updateAuthor": { "name": "shameerj", "key": "shameerj", "displayName": "Shameer Jan", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-04-19T09:17:30.000+0000", "updated": "2013-04-19T09:17:30.000+0000" }, { "id": "423839", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket due to time passed and lack of progress for a number of years. Please open a new ticket if there are any problems.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-07-10T22:30:52.000+0000", "updated": "2017-07-10T22:30:52.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }