Skip to content
This repository has been archived by the owner on Jan 15, 2023. It is now read-only.

Latest commit

 

History

History
69 lines (48 loc) · 3.04 KB

loading_html.md

File metadata and controls

69 lines (48 loc) · 3.04 KB

Loading Html

Chromely html loading (start url) can be done in 3 different ways.

  • A real website URL
  • Local/Embedded Resource Loading
  • File Protocol

A Real Website URL

This will launch actual website URL. This may not necessarily be commonly used as Chromely is focused on loading local HTML5 files for Single Page Applications (SPAs). This URL should also be of scheme and domain combination that is not registered as external URL scheme.

If the URL is pre-regisered as an external url scheme type, the URL will be opened by the OS default browser. Please see more info at Registering Url Schemes.

To load/start url and its assets, you can do it in configuration object:

    public class DefaultConfiguration : IChromelyConfiguration
    {
        public DefaultConfiguration()
        {
           StartUrl = "https://google.com";
        }
    }

Local Resource Loading

This is the preferred way of loading local HTML5 files.

Loading html and associated files via LocalResource needs a custom resource scheme handler. For more info on scheme handling, please see Registering Resource Handlers.

To load start url and its assets, you can do it in configuration object:

    public class DefaultConfiguration : IChromelyConfiguration
    {
        public DefaultConfiguration()
        {
           StartUrl = "local://app/chromely.html";
        }
    }

File Protocol

Local HTML5 files can also be loaded using file protocol (file:///). Using file protocol (file:///) is discouraged for security reasons. One issue might be Cross-Origin domain. Although not the preferred way, some developers may find need for it.

To load start url and its assets, you can do it in configuration object:

    public class DefaultConfiguration : IChromelyConfiguration
    {
        public DefaultConfiguration()
        {
			    var appDirectory = AppDomain.CurrentDomain.BaseDirectory;
			    var startUrl = $"file:///{appDirectory}app/chromely.html";
			    StartUrl = startUrl;
        }
    }

Notes:

  • Folder "app" is a physical folder in the executable folder. Usually this is the primary folder for all html and associated files. Sample - app folder. Usually all files in this folder are copied to executable (bin) folder.
  • For Angular/React/Vue this is usually the "dist" folder. So the start url usually is local://dist/index.html. The "dist" folder is where Webpack, Parcel and other bundlers publish the bundled (end product) for browsers consumption.