FAQ: HTML Web Engine: How is it possible to always jump to a specific start-screen after refreshing or reloading a Web Engine Website?

FAQ: HTML Web Engine: How is it possible to always jump to a specific start-screen after refreshing or reloading a Web Engine Website?

A specific start-screen can be open using the built-in solution automatic script call. See : Online Help: Individual Script call in HTML5 Web Engine Nevertheless, this will not cover a reloading web-engine (e.g. after updating the .webx files, deployment changes, server timeouts etc.).

In order to create a website, which will always open the same start-screen, a workaround has to be applied. In addition to that, there is also one constraint:  The Service Engine and Service Engine Connector must be running on the same machine. If the IIS host is on a different machine, cross-site scripting will block the workaround.

For the workaround, another website has to be deployed in the IIS and some adaptions have to be done in the project. The following steps must be executed on the zenon side:
  1. Create a regular web engine instance with the deployment tool (in this case the deployment name "myApplication" is used)
  2. In the Engineering Studio: Pick a standard screen which should be the start screen
  3. In the Engineering Studio: Create a screen-switch function and a script to call this function (e.g. myScript) , as described in the online help topic above.
  4. Create a function to execute the script (e.g. myScriptExecute).
  5. Activate the property "URL start function for web" in the Script properties
  6. Write down the script-call, as it would be performed in the web engine (in this example it would be: https://serveraddress/myApplication?startfunction=myScriptExecute )
  7. Compile the project and update the .webx file
Now, the IIS-Websites have to be adapted:
  1. Open the Internet Information Services (this can be done by typing "IIS" after pressing the windows-key)
  2. On the right pane, find the "Default Web Site"
  3. Perform a right click on the "Default Web Site" and click "Explore" in order to open the file explorer.
  4. Create a new folder and name it (e.g. Screen5). E.g. when you finished, the auto-script call will be available in: https://serveraddress/Screen5)
    The folder name will be your deployment name [DEPLOY_NAME].
  5. Manually create a new file "index.htm". Make sure you enabled to display file endings, otherwise the file might not be recognized as "htm".
  6. Open the "index.htm" file with an editor and paste the following code:
  ######################################################################################
 
<html>
         <body >
                   <iframe id="iframe_id" src="https://SERVER/DEPLOY_NAME/?startfunction=execScriptPage1" style="position:fixed; top:0; left:0; bottom:0; right:0; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;" name="targetframe" allowTransparency="true" frameborder="0" onLoad="checkUrl();">
                   </iframe>
         </body>        
         <script>
         var startUrl = " https://SERVER/DEPLOY_NAME/?startfunction=execScriptPage1";
         var checkUrl = function(){
                   if(document.getElementById("iframe_id").contentWindow.location.href.toUpperCase() != startUrl.toUpperCase()){
                            document.getElementById("iframe_id").src = startUrl;
                   }
         }
         </script>
</html>
 
######################################################################################

  After this, the URLs have to be adapted accordingly:
  1. Both URLs in the document have to be altered (the URL in iframe_id scr="" and in the var StartUrl ="").
  2. In this example, the URL would change from https://SERVER/DEPLOY_NAME/?startfunction=execScriptPage1 to -> https://serveradress/myApplication/?startfunction=MyScriptExecute
  3. Save the file. If you open it, the automatic script call should already work.
  4. Go to the IIS Manager and right clock on the web server. Hit "refresh"
  5. The automatic script call should now be available by using the URL: https://serveraddress/Screen5
The purpose of this code is to always perform a script call on the specific screen when the site is called/refreshed.
Since an Iframe is used to do this, the IIS host and the Service Engine must be on the same machine, otherwise this would violate the cross-site scripting policy of the browser.