Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23479] Windows: Local webview does not show any images, or opens other files.

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2016-06-30T07:24:45.000+0000
Affected Version/sRelease 5.3.0
Fix Version/sRelease 6.0.0
ComponentsWindows
Labelsn/a
ReporterSharif AbuDarda
AssigneeKota Iguchi
Created2016-06-07T07:37:43.000+0000
Updated2016-10-14T17:01:14.000+0000

Description

Hello, I have a local webpage which I want to open in webview. This works fine, But, I have an image, inside my webpage, which does not show when the webview opens. I am putting my html and image file in assets directory, which is not working. I even tried to put the files in lib directory, which also does not work. I also tried with hyperlink inside my webpage, which will open another local webpage. I can see the hyperlink in webview but clicking on it does not open my webpage. I am testing for both alloy and classic project. I am using SDK 5.2.2.GA and 5.3.0.GA.
var webview = Titanium.UI.createWebView({url:'logging.html});
    var window = Titanium.UI.createWindow();
    window.add(webview);
    window.open({modal:true});
<Alloy>
    <Window id="win" modal="true">
        <WebView id="webview" url="logging.html" />
    </Window>
</Alloy>
I have tested in android without any problem. Thanks.

Attachments

FileDateSize
logging.html2016-06-07T07:31:25.000+0000165
sample.jpg2016-06-07T07:31:29.000+0000325935

Comments

  1. Riyoko H 2016-06-08

    > I am using SDK 5.2.2.GA and 5.3.0.GA. Hi, These issues occur after 5.3.0.GA. :HTML can't display an image. hyperlink does not work. And it not occur in 5.2.2.GA in my environment.
  2. Kota Iguchi 2016-06-09

    Local links are not working because Windows Phone WebView (browser controls) doesn't allow local link unless you explicitly specify ms-appx-web://. I would suggest use of following workaround: For images:
       <img src="ms-appx-web:///sample.jpg">
       
    For local links:
       <a href="ms-appx-web:///NextPage.html">
       
  3. Riyoko H 2016-06-10

    Thank you for comment. I tried to change the html, it is shown jpeg file correctly. and I confirmed that HTML can call hyperlink. However, I'd like to put logging.html into "ms-appdata:///local/". and I can't access logging.html at "ms-appdata:///local/". How can I access logging.html within "ms-appdata:///local/"?
  4. Kota Iguchi 2016-06-13

    Looks like Windows WebView accepts local content only from sub directory of the root url where you WebView.Navigate (in Titanium it's WebView.url property). In addition to that, the file content in ms-appdata should be placed under subdirectory of local folder: {quote} The WebView support for this scheme requires you to place your content in a subfolder under the local or temporary folder. This enables navigation to URIs such as ms-appdata:///local/folder/file.html and ms-appdata:///temp/folder/file.html {quote} (See https://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.webview.aspx) So This mean you may need to copy index content to application data directory and navigate to ms-appdata:///local/xxx/index.html in order to load content under ms-appdata:///local/xxx/. Let say you have index content in application resource directory:
       function go() {
           var from = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, 'index.html');
           // todo: You'll need to create "webroot" subdirectory in this case before copying if it doesn't exist
           var to = Ti.Filesystem.applicationDataDirectory + 'webroot' + Ti.Filesystem.separator + 'index.html';
           from.copy(to);
       
          webview.url = 'ms-appdata:///local/webroot/index.html';
       }
       
    FYI http://wakiama.hatenadiary.jp/entry/2016/02/20/120728 (Japanese)
  5. Riyoko H 2016-06-13

    Thanks for your advice. I create new folder that named "webroot" in applicationDataDirectory, and copy HTML resourse file (ex.logging.html, sample.jpg) from ResourceDirectory. then, I can display logging.html where in "ms-appdata:///local/webroot/". but, "ms-appdata:///local/webroot/logging.html" can not display the referenced file:"ms-appdata:///local/webroot/sample1.jpg","ms-appdata:///local/webroot/logging2.html". I tried these HTML tags for display to "ms-appdata:///local/webroot/sample1.jpg". but "ms-appdata:///local/webroot/sample1.jpg" was not displayed. identically, I tried hyperlink, but these tags not worked. logging2.html logging2.html logging2.html logging2.html logging2.html logging2.html logging2.html How can I call "ms-appdata:///local/webroot/sample1.jpg" and "ms-appdata:///local/webroot/logging2.html" from "ms-appdata:///local/webroot/logging.html"?
  6. Kota Iguchi 2016-06-14

    I am able to reproduce the issue too. According to [this blog](http://wakiama.hatenadiary.jp/entry/2016/02/20/120728) relative link for ms-appdata should work, but it does not for me. Investigating.
  7. Kota Iguchi 2016-06-23

    https://github.com/appcelerator/titanium_mobile_windows/pull/749
  8. Ewan Harris 2016-10-14

    Verified using: OS: Microsoft Windows 10 Pro 10.0.14393 Appc core: 6.0.0-58 Appc NPM: 4.2.8-7 Ti SDK: 6.0.0.v20161013072802 Appc Studio: 4.8.0.201610060953 Lumia 550 10.0 Local webview now shows images stored locally on the device Closing ticket

JSON Source