Javascript example tutorial (19) use HoTMetal (6) _ basic knowledge

Source: Internet
Author: User
Javascript example tutorial (19) use HoTMetal (6) Use javascript in HoTMetal

6. how to write a script for saving the module

In the example in this tutorial, a new save module file dialog box is created. HoTMetaL has several templates you can choose from. The Template is just a common webpage, which is saved in the Template in the HoTMetaL application directory. When you select a new project From the File menu, one of the tag options is Page From Template. When you select it, a tag dialog box is displayed, which contains various templates: General, WebTV, W3C, Frame Pages, and Layout.

You can create a new Template by saving the current file to a directory under the Template directory. The following macro, the Save As template, shows you how to use the DisplayFileDlg method of HMExtras. FileDlg to create a Save As dialog box. This dialog box uses the Template directory as the default location. the detailed code is as follows:

<br><br>var obj = new ActiveXObject("HMExtras.FileDlg");<br><br>var filter = "Web Page Template (*.htm, *.html)|*.htm;*.html|All Files (*.*)|*.*||";<br><br>if (obj.DisplayFileDlg(0, "File Save As", filter, Application.Path + "\\Template")) {<br><br>ActiveDocument.SaveAs(obj.FullPathName, true); // save and put on recent file list <br><br>}<br><br>

The above code is explained below: first, we use the FileDlg COM object of the HMExtras library to create an ActiveX control:

Var obj = new ActiveXObject ("HMExtras. FileDlg ");

Then, use several entries to create a filter:

Var filter = "Web Page Template (*. htm, *. html) | *. htm; *. html | All Files (*. *) | *. * | ";

Then, we call obj. DisplayFileDlg to display the file dialog box. Finally, we save the file when the dialog box exists.
Use Javascript in HoTMetal

6. how to write a script for saving the module

Let's add the first Save As template macro to the File menu. You can click the menu bar of the file and choose custom. Then select the menu tag and navigate to the place where you want to add a new macro. Click Add Submenu and fill in the missing items. Dialog box 1 is displayed.


Next, let's test this menu item and how macros work. Pull down the File menu and you will see an additional Save Template item. click it and you will get the dialog box 2:

Find the directory where you want to Save the file and give the file name. click Save to confirm.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.