From Clomosy Docs
No edit summary |
ClomosyAdmin (talk | contribs) No edit summary |
||
| (5 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert"> | |||
function AddNewWebBrowser(AComponent: TCLComponent; xName: string): TclWebBrowser; | |||
</div> | |||
<span style="color:blue"><b>AComponent</b></span> : Specifies the parent of the object to be defined.<br> | |||
The | <span style="color:blue"><b>xName</b></span> : The name of the defined component should be written.<br> | ||
To integrate a web browser using Clomosy, you can use the TclWebBrowser component.<br> | |||
To use it, you should create a form and create a Web Browser inside it.<br> | |||
<pre> | |||
WebBrowser1 = Form1.AddNewWebBrowser(Form1,'WebBrowser1'); | |||
</pre> | |||
The 'Navigate' method is used to navigate the browser to the specified URL. This method is used when you want to load a specific web page.<br> | |||
<pre> | |||
WebBrowser1.Navigate('www.google.com'); | |||
</pre> | |||
The | The URL property is used to determine which URL the browser is navigating to. This property returns the URL of the currently loaded page in the browser as a string value. | ||
<pre> | |||
UrlStr = WebBrowser1.URL //UrlStr : String; | |||
</pre> | |||
Using the "goForward" function refers to going to a page in a web browser's history. That means returning to the previous page from an undone step in the browser.<br> | |||
<pre> | |||
WebBrowser1.goForward; | |||
</pre> | |||
It is used to go back from one page. Example: You searched on Google and want to return to the home page.<br> | |||
<pre> | |||
WebBrowser1.goBack; | |||
</pre> | |||
The CanGoBack feature specifies the browser's ability to go backwards. This property returns True if it is possible to go back one page; otherwise it returns False.<br> | |||
<pre> | |||
WebBrowser1.CanGoBack; | |||
</pre> | |||
<b>Example</b><br> | |||
<pre> | |||
Var | Var | ||
MyForm:TclForm; | MyForm:TclForm; | ||
xWeb:TclWebBrowser; | xWeb:TclWebBrowser; | ||
xBtn,xBtn2 : TCLButton; | xBtn,xBtn2 : TCLButton; | ||
xLyt: TclLayout; | xLyt : TclLayout; | ||
void goForwardClick; | |||
{ | |||
xWeb.goForward; | xWeb.goForward; | ||
} | |||
void goBackClick; | |||
{ | |||
if xWeb.CanGoBack | if (xWeb.CanGoBack) | ||
ShowMessage('You can return to the page.') | ShowMessage('You can return to the page.') | ||
else | else | ||
ShowMessage('There is no page to go back to.'); | ShowMessage('There is no page to go back to.'); | ||
xWeb.goBack; | xWeb.goBack; | ||
} | |||
{ | |||
MyForm | MyForm = TclForm.Create(Self); | ||
xLyt | xLyt = MyForm.AddNewLayout(MyForm,'xLyt'); | ||
xLyt.Align | xLyt.Align = alTop; | ||
xLyt.Height | xLyt.Height = 45; | ||
xBtn2 | xBtn2 = MyForm.AddNewButton(xLyt,'xBtn2','goBack'); | ||
xBtn2.Align | xBtn2.Align = alLeft; | ||
xBtn2.Width | xBtn2.Width = 70; | ||
MyForm.AddNewEvent(xBtn2,tbeOnClick,'goBackClick'); | MyForm.AddNewEvent(xBtn2,tbeOnClick,'goBackClick'); | ||
xBtn | xBtn = MyForm.AddNewButton(xLyt,'xBtn','goForward'); | ||
xBtn.Align | xBtn.Align = alLeft; | ||
xBtn.Width | xBtn.Width = 70; | ||
MyForm.AddNewEvent(xBtn,tbeOnClick,'goForwardClick'); | MyForm.AddNewEvent(xBtn,tbeOnClick,'goForwardClick'); | ||
xWeb | xWeb= MyForm.AddNewWebBrowser(MyForm,'xWeb'); | ||
xWeb.Align | xWeb.Align = alClient; | ||
xWeb.Navigate('www.google.com'); | xWeb.Navigate('www.google.com'); | ||
MyForm.Run; | MyForm.Run; | ||
} | |||
</pre> | |||
<h2> See Also </h2> | |||
* [[Components]] | |||
* [[Object Properties]] | |||
* [[AddNewEvent]] | |||
{{#seo:|title=TclWebBrowser Using in Clomosy - Clomosy Docs}} | |||
{{#seo:|description=Use TclWebBrowser in Clomosy to integrate a web browser into your app, enabling navigation, forward/backward history, and dynamic URL loading.}} | |||
Latest revision as of 14:56, 24 December 2024
function AddNewWebBrowser(AComponent: TCLComponent; xName: string): TclWebBrowser;
AComponent : Specifies the parent of the object to be defined.
xName : The name of the defined component should be written.
To integrate a web browser using Clomosy, you can use the TclWebBrowser component.
To use it, you should create a form and create a Web Browser inside it.
WebBrowser1 = Form1.AddNewWebBrowser(Form1,'WebBrowser1');
The 'Navigate' method is used to navigate the browser to the specified URL. This method is used when you want to load a specific web page.
WebBrowser1.Navigate('www.google.com');
The URL property is used to determine which URL the browser is navigating to. This property returns the URL of the currently loaded page in the browser as a string value.
UrlStr = WebBrowser1.URL //UrlStr : String;
Using the "goForward" function refers to going to a page in a web browser's history. That means returning to the previous page from an undone step in the browser.
WebBrowser1.goForward;
It is used to go back from one page. Example: You searched on Google and want to return to the home page.
WebBrowser1.goBack;
The CanGoBack feature specifies the browser's ability to go backwards. This property returns True if it is possible to go back one page; otherwise it returns False.
WebBrowser1.CanGoBack;
Example
Var
MyForm:TclForm;
xWeb:TclWebBrowser;
xBtn,xBtn2 : TCLButton;
xLyt : TclLayout;
void goForwardClick;
{
xWeb.goForward;
}
void goBackClick;
{
if (xWeb.CanGoBack)
ShowMessage('You can return to the page.')
else
ShowMessage('There is no page to go back to.');
xWeb.goBack;
}
{
MyForm = TclForm.Create(Self);
xLyt = MyForm.AddNewLayout(MyForm,'xLyt');
xLyt.Align = alTop;
xLyt.Height = 45;
xBtn2 = MyForm.AddNewButton(xLyt,'xBtn2','goBack');
xBtn2.Align = alLeft;
xBtn2.Width = 70;
MyForm.AddNewEvent(xBtn2,tbeOnClick,'goBackClick');
xBtn = MyForm.AddNewButton(xLyt,'xBtn','goForward');
xBtn.Align = alLeft;
xBtn.Width = 70;
MyForm.AddNewEvent(xBtn,tbeOnClick,'goForwardClick');
xWeb= MyForm.AddNewWebBrowser(MyForm,'xWeb');
xWeb.Align = alClient;
xWeb.Navigate('www.google.com');
MyForm.Run;
}