Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Hyperlink in Web Browser and ActiveXControl

Subject: Hyperlink in Web Browser and ActiveXControl

From: Mifano

Date: 24 Aug, 2007 12:52:24

Message: 1 of 15

I have a htm file called "TEMP.htm" which should NOT be
modified. This file includes the hyperlinks like :

<a href="matlab: !explorer
file:///D:\Dev_MBD_Minh\B_Devpt_fonctions\Setup\SimulinkBestPracticeCGMP.htm#AC">AC_2</a>

When I open this file by Web Browser in Matlab (command
web('url') ), the hyperlinks work correctly. However when I
try to display TEMP.htm on GUI by using:

hExp = actxcontrol('Shell.Explorer.2',conSize,gcf);
Navigate2(hExp,filepath);

this page is displayed but none of hyperlink works. I
receive the same error when I use Internet Explorer to open
TEMP.htm.
It says that the protocol "matlab" is unknown.

Could you tell me how to display the TEMP.htm on GUI correctly?

Subject: Hyperlink in Web Browser and ActiveXControl

From: Yair Altman

Date: 24 Aug, 2007 14:12:02

Message: 2 of 15

"Mifano " <nchminh@gmail.com> wrote in message
<famka8$5k7$1@fred.mathworks.com>...
> I have a htm file called "TEMP.htm" which should NOT be
> modified. This file includes the hyperlinks like :
>
> <a href="matlab: !explorer
>
file:///D:\Dev_MBD_Minh\B_Devpt_fonctions\Setup\SimulinkBestPracticeCGMP.htm#AC">AC_2</a>
>
> When I open this file by Web Browser in Matlab (command
> web('url') ), the hyperlinks work correctly. However when
> I try to display TEMP.htm on GUI by using:
>
> hExp = actxcontrol('Shell.Explorer.2',conSize,gcf);
> Navigate2(hExp,filepath);
>
> this page is displayed but none of hyperlink works. I
> receive the same error when I use Internet Explorer to open
> TEMP.htm. It says that the protocol "matlab" is unknown.
>
> Could you tell me how to display the TEMP.htm on GUI
correctly?


matlab: is indeed NOT a valid protocol recognized by regular
browsers. When you use web(), Matlab uses an internal
browser to view the requested page - this internal browser
DOES recognize the matlab: protocol. So, if these links are
important for you, keep using web().

Yair Altman
http://ymasoftware.com

Subject: Hyperlink in Web Browser and ActiveXControl

From: Mifano

Date: 24 Aug, 2007 14:26:05

Message: 3 of 15

"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message
<famovi$l5o$1@fred.mathworks.com>...

> matlab: is indeed NOT a valid protocol recognized by regular
> browsers. When you use web(), Matlab uses an internal
> browser to view the requested page - this internal browser
> DOES recognize the matlab: protocol. So, if these links are
> important for you, keep using web().
>
> Yair Altman
> http://ymasoftware.com
>

Thank you Yair Altman.
 
Theses links are important cause they link to Simulink
models as well, so I think I must use web().

The question is: Is there some way to display a web page by
using web() on GUI?

Thanks a lot.

Subject: Hyperlink in Web Browser and ActiveXControl

From: Yair Altman

Date: 25 Aug, 2007 19:57:27

Message: 4 of 15

"Mifano " <nchminh@gmail.com> wrote in message
<famppt$4q8$1@fred.mathworks.com>...
> <snip>Is there some way to display a web page by
> using web() on GUI?

Not easily: web() opens a separate browser window which you
cannot embed in a GUI. However, you can use the following
undocumented hack to do this:

url = 'www.cnn.com';
browser = com.mathworks.mlwidgets.html.HTMLBrowserPanel(url);
pos = [10,10,400,300];
javacomponent(browser,pos,gcf);

You can add toolbar etc. by activating methods on the
browser object as follows (type "methodsview(browser)" for
the full list):

browser.addToolbar;

Yair Altman
http://ymasoftware.com

Subject: Hyperlink in Web Browser and ActiveXControl

From: Mifano

Date: 27 Aug, 2007 07:04:32

Message: 5 of 15

"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message
<faq1j7$pj0$1@fred.mathworks.com>...
> "Mifano " <nchminh@gmail.com> wrote in message
> <famppt$4q8$1@fred.mathworks.com>...
> > <snip>Is there some way to display a web page by
> > using web() on GUI?
>
> Not easily: web() opens a separate browser window which you
> cannot embed in a GUI. However, you can use the following
> undocumented hack to do this:
>
> url = 'www.cnn.com';
> browser = com.mathworks.mlwidgets.html.HTMLBrowserPanel(url);
> pos = [10,10,400,300];
> javacomponent(browser,pos,gcf);
>
> You can add toolbar etc. by activating methods on the
> browser object as follows (type "methodsview(browser)" for
> the full list):
>
> browser.addToolbar;
>
> Yair Altman
> http://ymasoftware.com
>

Thank you, that's really helpful.

Subject: Hyperlink in Web Browser and ActiveXControl

From: Mifano

Date: 29 Aug, 2007 08:10:41

Message: 6 of 15

"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message
<faq1j7$pj0$1@fred.mathworks.com>...
> "Mifano " <nchminh@gmail.com> wrote in message
> <famppt$4q8$1@fred.mathworks.com>...
> > <snip>Is there some way to display a web page by
> > using web() on GUI?
>
> Not easily: web() opens a separate browser window which you
> cannot embed in a GUI. However, you can use the following
> undocumented hack to do this:
>
> url = 'www.cnn.com';
> browser = com.mathworks.mlwidgets.html.HTMLBrowserPanel(url);
> pos = [10,10,400,300];
> javacomponent(browser,pos,gcf);
>
> You can add toolbar etc. by activating methods on the
> browser object as follows (type "methodsview(browser)" for
> the full list):
>
> browser.addToolbar;
>
> Yair Altman
> http://ymasoftware.com
>


Thank you for your reply. I followed your instruction and
succeeded to embed Web browser to GUI.
However, I didn't found any document about the class
com.mathworks.mlwidgets.html.HTMLBrowserPanel.
The methodsview gives me few information about syntax of the
class's functions.
Could you tell me where to find these documents? Actually,
I'm looking for the refresh and resize functions of this web
page.
Thank you very much.

Subject: Hyperlink in Web Browser and ActiveXControl

From: Yair Altman

Date: 29 Aug, 2007 08:51:29

Message: 7 of 15

> "Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message
> > <snip>you can use the following
> > undocumented hack to do this:
>
> However, I didn't found any document about the class
> com.mathworks.mlwidgets.html.HTMLBrowserPanel.
> Could you tell me where to find these documents?

As I said above, it's UNDOCUMENTED (which means, well,
there's no documentation). It's an internal Matlab class
that is not meant to be used by anyone outside MathWorks.
You can use it, but you're on your own here...

> I'm looking for the refresh and resize functions of this
> web page.

You can get/set the browser object properties in the regular
Matlab fashion, using the get/set functions:

browser=com.mathworks.mlwidgets.html.HTMLBrowserPanel(url);
get(browser)
set(browser,propertyName,newValue);

You can also do the same for the objects returned by the
javacomponent function (including updating the component's
position, units etc.)

Yair Altman

Subject: Hyperlink in Web Browser and ActiveXControl

From: Mifano

Date: 30 Aug, 2007 09:15:32

Message: 8 of 15

"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message
<fb3c2h$kf9$1@fred.mathworks.com>...
> > "Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message
> > > <snip>you can use the following
> > > undocumented hack to do this:
> >
> > However, I didn't found any document about the class
> > com.mathworks.mlwidgets.html.HTMLBrowserPanel.
> > Could you tell me where to find these documents?
>
> As I said above, it's UNDOCUMENTED (which means, well,
> there's no documentation). It's an internal Matlab class
> that is not meant to be used by anyone outside MathWorks.
> You can use it, but you're on your own here...
>
> > I'm looking for the refresh and resize functions of this
> > web page.
>
> You can get/set the browser object properties in the regular
> Matlab fashion, using the get/set functions:
>
> browser=com.mathworks.mlwidgets.html.HTMLBrowserPanel(url);
> get(browser)
> set(browser,propertyName,newValue);
>
> You can also do the same for the objects returned by the
> javacomponent function (including updating the component's
> position, units etc.)
>
> Yair Altman
>


Thank you for you reply. Could you please answer to some
questions related:

1) Problem 1

I tried this code sample:

figure(1)
url = 'www.google.com';
browser = com.mathworks.mlwidgets.html.HTMLBrowserPanel(url);
pos = [10,10,400,300];
jCompObj = javacomponent(browser,pos,gcf);

% Get current dimension
jCompObj.Width
jCompObj.Height

% Change dimension
jCompObj.setSize(10,10) ;

% Verify dimension
jCompObj.Width
jCompObj.Height

The new dimension of browser now is 10x10 but on figure(1),
there's nothing changed (the dimension of web page is always
    400x300).

Could you tell me how to update the modification of these
properties.

2) Problem 2

Some time I have to modify the file in 'url'. How can I
"refresh" the web page on figure?

Thank you very much

Subject: Hyperlink in Web Browser and ActiveXControl

From: Yair Altman

Date: 30 Aug, 2007 14:46:02

Message: 9 of 15

> 1) Problem 1
>
> figure(1)
> url = 'www.google.com';
> browser = com.mathworks.mlwidgets.html.HTMLBrowserPanel(url);
> pos = [10,10,400,300];
> jCompObj = javacomponent(browser,pos,gcf);
>
> % Get current dimension
> jCompObj.Width
> jCompObj.Height
>
> % Change dimension
> jCompObj.setSize(10,10) ;
>
> % Verify dimension
> jCompObj.Width
> jCompObj.Height
>
> The new dimension of browser now is 10x10 but on figure(1),
> there's nothing changed (the dimension of web page is always
> 400x300).
>
> Could you tell me how to update the modification of these
> properties.

[jCompObj,hCompObj] = javacomponent(browser,pos,gcf);
set(hCompObj,'pos',[30,30,600,200]);
set(hCompObj, 'units','normalized', 'pos',[.1,.2,.3,.4]); %
better

> 2) Problem 2
>
> Some time I have to modify the file in 'url'. How can I
> "refresh" the web page on figure?

browser.setCurrentLocation('www.cnn.com');

Yair Altman

Subject: Hyperlink in Web Browser and ActiveXControl

From: Jan Paskarbeit

Date: 6 Dec, 2007 20:35:57

Message: 10 of 15

Hello!
How can I delete the browserobject again? When I load an
automatically reloading webpage (<body
onLoad="setTimeout('window.location.reload()', 1000)">) and
close the figure, the cursor still changes once per second
into the hour glass cursor, so I guess that the browser
still exists tough the figure is closed.
Thanks,
Jan

Subject: Hyperlink in Web Browser and ActiveXControl

From: Yair Altman

Date: 12 Jan, 2009 20:45:04

Message: 11 of 15

> How can I delete the browserobject again? When I load an
> automatically reloading webpage (<body
> onLoad="setTimeout('window.location.reload()', 1000)">) and
> close the figure, the cursor still changes once per second
> into the hour glass cursor, so I guess that the browser
> still exists tough the figure is closed.

clear the browserobject handle - closing the figure does not necessarily delete the handle and if you still have it in your workspace then it will still be available, even without a figure window.

Subject: Hyperlink in Web Browser and ActiveXControl

From: karthikeyan

Date: 27 Jan, 2009 07:58:04

Message: 12 of 15

"Mifano " <nchminh@gmail.com> wrote in message <fatt20$cuj$1@fred.mathworks.com>...
> "Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message
> <faq1j7$pj0$1@fred.mathworks.com>...
> > "Mifano " <nchminh@gmail.com> wrote in message
> > <famppt$4q8$1@fred.mathworks.com>...
> > > <snip>Is there some way to display a web page by
> > > using web() on GUI?
> >
> > Not easily: web() opens a separate browser window which you
> > cannot embed in a GUI. However, you can use the following
> > undocumented hack to do this:
> >
> > url = 'www.cnn.com';
> > browser = com.mathworks.mlwidgets.html.HTMLBrowserPanel(url);
> > pos = [10,10,400,300];
> > javacomponent(browser,pos,gcf);
> >
> > You can add toolbar etc. by activating methods on the
> > browser object as follows (type "methodsview(browser)" for
> > the full list):
> >
> > browser.addToolbar;
> >
> > Yair Altman
> > http://ymasoftware.com
> >
>
> Thank you, that's really helpful.

Hi Yair Altman,

I have been creating the Matlab GUI in which to display the html file, the file contains some matlab command in the few lines.

Initially, I was working using activexcontrol where i found it difficult to invoke matlab commands.

Recently, I saw your reply using ".HTMLBrowserPanel" which will resolve my issue but i need some action in addition to the display the html file.

1. I need to know the way to get the selected text in the html file. I mean that if i would select some text using mouse in the displayed html file. How do i get it? what's the way from browser data structure.

2. If i display the multiple html files in the same browser, I need to switch between the html file without refreshing(It's mandatory). Of course, I can addToolbar where i can click Back and Forward buttons, But i need an API to invoke Back and Forward

Thanks in advance

Subject: Hyperlink in Web Browser and ActiveXControl

From: Yair Altman

Date: 27 Jan, 2009 08:49:03

Message: 13 of 15

> 1. I need to know the way to get the selected text in the html file. I mean that if i would select some text using mouse in the displayed html file. How do i get it? what's the way from browser data structure.

url = 'www.cnn.com';
browser = com.mathworks.mlwidgets.html.HTMLBrowserPanel(url);
pos = [10,10,400,300];
javacomponent(browser,pos,gcf);

browserCanvas = browser.getHTMLRenderer.getComponent(0).getComponent(0);
browserCanvas.getSelectedText;

> 2. If i display the multiple html files in the same browser, I need to switch between the html file without refreshing(It's mandatory). Of course, I can addToolbar where i can click Back and Forward buttons, But i need an API to invoke Back and Forward

browser.setCurrentLocation('www.bbc.com');
browserCanvas.goBack; % =>CNN, use browserCanvas.getURL to check
browserCanvas.goForward; % =>BBC, use browserCanvas.getURL to check

The exact methods/properties of browserCanvas may depend on your default browser.

Yair Altman
http://ymasoftware.com

Subject: Hyperlink in Web Browser and ActiveXControl

From: karthikeyan

Date: 27 Jan, 2009 14:32:01

Message: 14 of 15

"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message <glmhpv$7if$1@fred.mathworks.com>...
> > 1. I need to know the way to get the selected text in the html file. I mean that if i would select some text using mouse in the displayed html file. How do i get it? what's the way from browser data structure.
>
> url = 'www.cnn.com';
> browser = com.mathworks.mlwidgets.html.HTMLBrowserPanel(url);
> pos = [10,10,400,300];
> javacomponent(browser,pos,gcf);
>
> browserCanvas = browser.getHTMLRenderer.getComponent(0).getComponent(0);
> browserCanvas.getSelectedText;
>
> > 2. If i display the multiple html files in the same browser, I need to switch between the html file without refreshing(It's mandatory). Of course, I can addToolbar where i can click Back and Forward buttons, But i need an API to invoke Back and Forward
>
> browser.setCurrentLocation('www.bbc.com');
> browserCanvas.goBack; % =>CNN, use browserCanvas.getURL to check
> browserCanvas.goForward; % =>BBC, use browserCanvas.getURL to check
>
> The exact methods/properties of browserCanvas may depend on your default browser.
>
> Yair Altman
> http://ymasoftware.com

Hi Yair Altman,

Yes, It's work well. But if i would load the multiple(more than six) html files, it's not working exactly. I just added pause command before loading(using setCurrentLocation) each file.

I couldn't see the location bar in the browser I feel it would be better to view the file URL in location bar( or is it an address bar) as there are multiple files.

Subject: Hyperlink in Web Browser and ActiveXControl

From: karthikeyan

Date: 27 Jan, 2009 14:36:02

Message: 15 of 15

"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message <glmhpv$7if$1@fred.mathworks.com>...
> > 1. I need to know the way to get the selected text in the html file. I mean that if i would select some text using mouse in the displayed html file. How do i get it? what's the way from browser data structure.
>
> url = 'www.cnn.com';
> browser = com.mathworks.mlwidgets.html.HTMLBrowserPanel(url);
> pos = [10,10,400,300];
> javacomponent(browser,pos,gcf);
>
> browserCanvas = browser.getHTMLRenderer.getComponent(0).getComponent(0);
> browserCanvas.getSelectedText;
>
> > 2. If i display the multiple html files in the same browser, I need to switch between the html file without refreshing(It's mandatory). Of course, I can addToolbar where i can click Back and Forward buttons, But i need an API to invoke Back and Forward
>
> browser.setCurrentLocation('www.bbc.com');
> browserCanvas.goBack; % =>CNN, use browserCanvas.getURL to check
> browserCanvas.goForward; % =>BBC, use browserCanvas.getURL to check
>
> The exact methods/properties of browserCanvas may depend on your default browser.
>
> Yair Altman
> http://ymasoftware.com

Hi Yair Altman,

Yes, It's work well. But if i would load the multiple(more than six) html files, it's not working exactly. I just added pause command before loading(using setCurrentLocation) each file.

I couldn't see the location bar in the browser I feel it would be better to view the file URL in location bar( or is it an address bar) as there are multiple files.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us