Main Content

matlab.htmlviewer.HTMLViewer

R2026b

HTML Viewer tab

Since R2025a

    Description

    The matlab.htmlviewer.HTMLViewer class represents an HTML tab open in the HTML Viewer.

    The HTML Viewer loads content from local files only. Store supporting files, such as JavaScript and CSS files, in the same folder as the HTML file or in a subfolder and reference them using relative paths. Third-party JavaScript libraries must also be saved locally. Libraries hosted on Content Delivery Networks (CDNs) are not accessible.

    Note

    Security Considerations: Only open trusted HTML files in the HTML Viewer. If an HTML file comes from an unknown user or an uncontrolled source, open it in your default web browser instead.

    Creation

    When you use the web function to open a local URL or file, the function returns a matlab.htmlviewer.HTMLViewer object.

    Properties

    expand all

    Last specified input for the HTML Viewer tab, specified as a string scalar. If you open a tab using the web function without specifying an input, Input is empty.

    Whether the contents of the HTML Viewer tab are visible, specified as a numeric or logical 1 (true) or 0 (false). Set this property to false to hide the contents of the HTML Viewer tab and show a blank page instead. Set this property to true to show the contents of the HTML Viewer tab and bring focus to the tab.

    Object Functions

    getHTMLTextGet contents of HTML Viewer tab

    Examples

    collapse all

    Create a local HTML file by publishing an example program file.

    htmlFile = publish("penny.m",outputDir=pwd);

    View the file in the HTML Viewer using the web function by specifying the filename. The web function returns the status of the operation and a handle to the HTML Viewer tab.

    [stat,h] = web(htmlFile);

    Set the Visible property to hide the contents of the HTML Viewer tab.

    h.Visible = false

    Limitations

    • The HTML Viewer does not display .bmp (bitmap) image files. Instead use .png, .gif, or .jpeg formats for image files in HTML pages.

    • In an installed version of MATLAB®, certain HTML features, such as web plugins and access to webcams or microphones, are not supported.

    Version History

    Introduced in R2025a

    expand all