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:
- Create a regular web engine instance with the deployment tool (in this case the deployment name "myApplication" is used)
- In the Engineering Studio: Pick a standard screen which should be the start screen
- 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.
- Create a function to execute the script (e.g. myScriptExecute).
Activate the property "URL start function for web" in the Script properties
- 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 )
- Compile the project and update the .webx file
Now, the IIS-Websites have to be adapted:
- Open the Internet Information Services (this can be done by typing "IIS" after pressing the windows-key)
- On the right pane, find the "Default Web Site"
- Perform a right click on the "Default Web Site" and click "Explore" in order to open the file explorer.
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].
- Manually create a new file "index.htm". Make sure you enabled to display file endings, otherwise the file might not be recognized as "htm".
- 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:
- Both URLs in the document have to be altered (the URL in iframe_id scr="" and in the var StartUrl ="").
In this example, the URL would change from https://SERVER/DEPLOY_NAME/?startfunction=execScriptPage1 to -> https://serveradress/myApplication/?startfunction=MyScriptExecute
- Save the file. If you open it, the automatic script call should already work.
- Go to the IIS Manager and right clock on the web server. Hit "refresh"
- 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.