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

Loading HTML

Robin Gabriël edited this page Jan 24, 2020 · 4 revisions

Note: In some of the following code snippets, the HTML file is stored under the folder app/. It's not required to be under app/. Feel free to create your file structure as you see fit, this is just an example.

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 SPAs (Single Page Applications).

This URL should also be of scheme and domain combination that is not registered as external URL scheme. For external URL scheme registration, please Registering Url Schemes.

To load start url and its assets, you can configure it either in config file or via C# code.

  • Using config file
"startUrl": {
   "url": "https://google.com",
   "loadType": "absolute"
}
  • Using C# code
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 either in config file or configuration object:

"startUrl": {
   "url": "local://app/chromely.html",
   "loadType": "localResource"
}
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, it is useful if HTML/Ajax XHR requests are required.

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

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