Use a script to customise a web page
This exercise describes how to use a script to configure the behaviour of a WebBrowser in a form:
- Click and drag a WebBrowser from the Toolbox to the Design Sheet:
- Click the Properties tab to display the properties of the WebBrowser control:
Resize
Click and drag the corners of the control to resize the control.
Reposition
Click and drag the handle (top-left) to reposition the control.
(If the Properties pane is not already open, you can open it via the Properties button on the ribbon.)
Save your changes and click Run to run the form:
When you open the Scripts pane, and a control is selected in the form, any functions associated with the properties of that control are shown in the Scripts pane. You can navigate the script using a list of functions at the top of the Scripts pane:
The properties that can be linked to a function includes the events listed in the Events View of the Properties pane. Events define the behaviour of a control, for example, what happens when the mouse is clicked on or positioned over a control. When you double-click on an event in the Events View, the associated function for that event is referenced in the View and is loaded in the Scripts pane.
In this example, scripts have been created to enhance the embedded web browser by creating buttons to provide Back, Forward, Refresh and Loading Status functionality.
Note how the Loaded event is set to execute the WebHelpBrowser_Loaded function, and how the PropertyChanged event is set to execute the: WebHelpBrowser_PropertyChanged script:

The following functions are used to populate a ComboBox with a list of site link options and to program the behaviour of Back, Forward and Reload buttons used with an embedded Web Browser control:
#variables HelpLinks = [['Geobank Web Help','http://webhelp.micromine.com/gb/11.0/English/Geobank.htm'],['Base Datamodels','http://webhelp.micromine.com/gb/11.0/English/Geobank.htm#cshid=1014'],['MICROMINE Blog','https://www.micromine.com/blog/'],['Geobank News','https://www.micromine.com/category/geobank/'],['Geobank For Field Teams News','https://www.micromine.com/category/geobank-mobile/']] def Grid1_Loaded(sender, e): WebHelpCombo.Items.Clear() for link in HelpLinks: WebHelpCombo.Items.Add(link[0]) #Console.Items.Add(link[1]) WebHelpCombo.SelectedIndex = 0 def WebHelpCombo_SelectionChanged(sender, e): selection = WebHelpCombo.SelectedIndex url = HelpLinks[selection][1] ProgressLabel.Content = 'Viewing: '+url WebHelpBrowser.Address = url def PortalBrowser_Loaded(sender, e): PortalBrowser.ToolTip = PortalBrowser.Address def WebHelpBrowser_Loaded(sender, e): ProgressLabel.Content = '' def HelpBackButton_Click(sender, e): if WebHelpBrowser.CanGoBack: WebHelpBrowser.BackCommand.Execute('') def HelpForwardButton_Click(sender, e): if WebHelpBrowser.CanGoForward: WebHelpBrowser.ForwardCommand.Execute('') def HelpReloadButton_Click(sender, e): WebHelpCombo_SelectionChanged(sender, e) def WebHelpBrowser_PropertyChanged(sender, e): ProgressLabel.Content = 'Viewing: '+WebHelpBrowser.Address