Home >Web Front-end >JS Tutorial >Javascript example tutorial (19) Using HoTMetal (6)_Basic knowledge

Javascript example tutorial (19) Using HoTMetal (6)_Basic knowledge

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 19:22:25979browse
Using javascript in HoTMetal

6. How to write a save module script

In the example of this tutorial, we created a new save module file dialog box. There are several templates in HoTMetaL that you can choose from. A template is just an ordinary web page, which is saved in the Template template in the HoTMetaL application directory. When you select New Project from the File menu, one of the tab options is Page From Template. When you select it, a label dialog box will pop up, containing various templates: General, WebTV, W3C, Frame Pages, 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 create a Save As dialog box using the DisplayFileDlg method of HMExtras.FileDlg. This dialog box uses the Template directory as the default location. The following is the detailed code:


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

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

if (obj.DisplayFileDlg(0, "File Save As", filter, Application.Path "\Template")) {

ActiveDocument.SaveAs(obj.FullPathName, true); // save and put on recent file list

}

]]>


Let’s explain the above code: First, we use the FileDlg COM object of the HMExtras library to create a 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 display it by calling obj.DisplayFileDlg file dialog, and finally we save the file if the dialog exists.
Using Javascript in HoTMetal

6. How to write a save module script

Let us add the first Save As template macro to the file menu. You can click on the File menu bar and select Customize. Then select the Menu tab and navigate to where you want to add the new macro. Click the Add Submenu button and fill in the missing items. The dialog box is shown in Figure 1.

Javascript example tutorial (19) Using HoTMetal (6)_Basic knowledge

(Picture 1)

Let’s test how this menu item and the macro work. Pull down the file menu and you will see an additional Save template item. Click it and you will get the dialog box as shown in Figure 2:

Javascript example tutorial (19) Using HoTMetal (6)_Basic knowledge

Find the file you want to save. Directory and give the file name, click the Save button to confirm.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn