This repository demonstrates how to use OpenFin preload scripts to navigate to the originally loaded url in a view if the user navigates away and then reloads/refreshes the page.
Preload scripts can be defined in window and view options or as part of a manifest. This example defines the view level preload via the manifest.
The manifest in public/manifest.fin.json shows how you can add a preload script to all views (using the default options setting).
The preload script is injected into the view (which starts of on google.com). Reloading the view at this stage does nothing. If you navigate to a different page and reload the page (you can use right-click reload or location.reload() via the developer console) then you will end up back at the original url. If you use the console settings in developer tools to preserve logs then you will see all the interactions logged out.
Follow the instructions below to get up and running.
- Install dependencies and do the initial build. Note that these examples assume you are in the sub-directory for the example.
npm run setup
- Build the project.
npm run build
- Start the test server in a new window.
npm run start
- Start the Platform application.
npm run client
-
A platform window loading google.com
-
Right click and reload and open the developer tools to see that the preload script has loaded and has detected that a reload of the page occurred.
-
In the developer tools if you select preserve log then you will see the interactions of the next few steps.
-
With the developer tools still open click on one of the search results.
-
Right click and reload.
-
The view should have navigated back to google.com and the console should show that it detected that a reload event happened and it wasn't on the initial url which is why it navigated back to google.
This is an example of how to use OpenFin APIs to configure OpenFin Container. Its purpose is to provide an example and suggestions. DO NOT assume that it contains production-ready code. Please use this as a guide and provide feedback. Thanks!