The WebBrowser class represents a web browser control.
// create our own class derived from Form
class MyForm extends Form {
url_textbox = null;
browser = null;
constructor() {
super("Mini Browser", 100, 100, 800, 600);
this.url_textbox = new TextBox("http://www.google.com", 0, 0, 500);
this.url_textbox.enterPressed.connect(this, this.onUrlEnterPressed);
this.browser = new WebBrowser(0, 50, 500, 350);
this.browser.navigate("http://www.google.com");
// vertical sizer
const main_layout = new BoxLayout(Layout.Vertical);
main_layout.add(this.url_textbox, 0, Layout.Expand | Layout.All, 5);
main_layout.add(this.browser, 1, Layout.Expand | Layout.Left | Layout.Right | Layout.Bottom, 5);
this.setLayout(main_layout);
}
onUrlEnterPressed() {
// user pressed enter, navigate to the new location
this.browser.navigate(this.url_textbox.getText());
}
}
// create an instance of our derived MyForm class
// and show it
const f = new MyForm();
f.show();
// start the event loop
Application.run(); Returns true if there's a selection in the web control that can be copied, and false otherwise.
Returns true if there's a selection in the web control that can be cut, and false otherwise.
Returns true if the current contents of the system clipboard can be pasted, and false otherwise.
Returns the current URI for the web control.
Returns the current URI for the web control.
Opens the previous URI in the list of navigated URIs.
Opens the next URI in the list of navigated URIs.
Reloads the current URI in the web control.
true if the operation succeeded, false otherwise
Display's the text passed in the html_text parameter in the browser control.
Stops the web control from loading a URI that's currently being loaded.
Calling this method will cause execution to wait until the web browser has finished loading the web document. It is normally invoked after a call to navigate() is issued. The optional parameter, max_milliseconds, specifies the maximum amount of time the call should wait before returning. If no parameter is specified, the method will wait indefinitely.