3

I have a compiled matlab application, which has a gui. This gui also contains a webpage within it, index.html. In the html, there is a hyperlink to a website. I want matlab to load the webpage in an external browser when this link is clicked. currently, this is the hyperlink I use:

<a href="matlab:web('http://www.google.com','-browser')">Help</a>

However, when clicked, the compiled program crashes and closes immediately. This does NOT happen when I start the program from within matlab; in this case it works as expected (and wanted). The effect is only present when the application is compiled. Why is this? Is there any way to fix it?

EDIT: here is a a simple verifiable example, etc.

first the simple matlab code:

% Create a blank figure window
f=figure('Name','Browser GUI Fail','Units','norm');

% Add the browser object
com.mathworks.mlwidgets.html.HTMLRenderer.setUseWebRenderer(false);
jObject = com.mathworks.mlwidgets.html.HTMLBrowserPanel;
[browser,container] = javacomponent(jObject, [], f);

set(container,'Units','normalized','Position',[0 0 1 1 ]);
url=['file:/'  which('index.html') ];
browser.setCurrentLocation(url);

second, the html file, index.html

<!DOCTYPE html>
<html>
<body>

<p>stuff, anything at all <a href="matlab:web('http://www.google.com','-browser')">Help</a> </p>

</body>
</html>

The link fails in the compiled version of the program. I am on Windows, and using 2014b.

Jgd10
  • 497
  • 2
  • 14
  • Is it possible for you to add a [mcve] so it can be tested? – Ander Biguri Oct 18 '18 at 11:03
  • Unfortunately, no. This is part of a program I am contributing to that is confidential and I did not write the part that embeds the webpage into the gui. The old webpage had no hyperlinks and worked fine. The new webpage is identical, still works fine, but the hyperlinks fail. This only happens when it is compiled. I could provide an example html file, but it would just contain the text of the hyperlink above. If this is just a case of 'compiled matlab can't do that' then that's fine. – Jgd10 Oct 18 '18 at 11:32
  • Without more details its hard to help - one thing you could try is run the exe from a dos prompt to see if it throws any errors that help explain the issue. – matlabgui Oct 18 '18 at 12:55
  • 1
    @J.Derrick sorry, please read the link. I do not want the program,please do not share it, its probably too big. I want a minimal example that reproduces the problem. A complete minimal example. – Ander Biguri Oct 18 '18 at 13:23
  • You don't mention what OS you're using, but in Windows I solved this problem in a compiled GUI by using a dos call. `dos('start http://www.google.com');` – jgrant Oct 18 '18 at 13:54
  • @jgrant sorry I'm on Windows; I will try that! – Jgd10 Oct 18 '18 at 14:09
  • 2
    @jgrant, this has worked for me; if you put it as an answer, I'll accept it – Jgd10 Oct 18 '18 at 14:27

1 Answers1

3

I had a similar problem in a Windows compiled GUI and I solved it using a dos call.

dos('start http://www.google.com');

jgrant
  • 1,273
  • 1
  • 14
  • 22