Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-26855

Windows: Add "baseURL" support to WebView.setHtml()

    Details

    • Story Points:
      8
    • Sprint:
      2019 Sprint 7, 2019 Sprint 10

      Description

      Summary:
      Titanium currently documents that the WebView.setHtml() method supports a 2nd argument on Android and iOS which can provide a "baseURL" setting. Android used to support this, but it was inadvertently removed in Titanium 6.0.3. This feature should be re-added since it's needed by "iframes" to indicate which URL an iframe's embedded paths are relative to.

      For example, a YouTube video embedded within an iframe will not play on Android or iOS unless a "baseURL" of "https://www.youtube.com" is provided.

      Steps to reproduce:

      1. Build and run the below code on Android.
      2. Tap on the video to attempt to play it.
      3. Notice that the video won't play. Instead it reads "Video Unavailable".
      4. Build and run on iOS.
      5. Tap on the video play it.
      6. Notice that the video plays fine. (This is because the "baseURL" is being used.)

      var htmlText =
      		'<!DOCTYPE html>' +
      		'<html>' +
      		'	<body>' +
      		'		<iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen/>' +
      		'	</body>' +
      		'</html>';
       
      var window = Ti.UI.createWindow();
      var webView = Ti.UI.createWebView();
      //webView.html = htmlText;
      webView.setHtml(htmlText, { baseURL: "https://www.youtube.com" });
      window.add(webView);
      window.open();
      

      Work-Around:
      The "baseURL" is not needed if the webpage was loaded from the Internet (ie: the "url" property). That is, "baseURL" is only applicable when loading HTML from string. So, hosting the webpage on your own web server will work-around this problem.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kiguchi Kota Iguchi
                Reporter:
                jquick Joshua Quick
                Reviewer:
                Gary Mathews
                Tester:
                Samir Mohammed
              • Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Source Code