This Domain(Admin5.com) is for Sale:

Javascript实例教程(19) 使用HoTMetal(4)

时间:2007-10-22  来源:不详  作者:林子




(图1)

现在假设你想格式化文档中所选择的部分。这个请求的宏(称为Format Current Selection)跟上面所述的宏(Format Current Document)很类似。它们之间的不同只是在:Format Current Document中 Layout()方法是操作ActiveDocument 对象,而Format Current Selection中 Layout()方法是操作Selection对象:

<MACRO name="Format Current Selection" lang="JScript" id="53" desc="Apply source layout to the current selection">

<![CDATA[

if (ActiveDocument.ViewType == viewSource) {

Selection.Layout();

} else{

Application.Alert("Applying source layout only works in source view.Switch to source view and try again.");

}

]]></MACRO>
下面让我们好好看看上面这个宏是如何工作的。我们在打开的文档中缩进了两行。第一行是以”does not specify”开头的,而另外一句是以"referred to in this ma:"开头的。如图2所示:



(图2)

现在我们选择三行,这三行包括了以"does not specify:"开头的行,如图3所示: dedecms.com



(图3)

最后我们点击中在窗口左上角上的绿色箭头,接着宏的名字(Format Current Selection)就显示在下拉菜单的窗口中,如图4所示:



(图4)

值得一提的是,被选择的行已经被格式化为原来的段落边界。以"referred to in this ma"为开头的第二行保持缩进状态而没有被格式化。

看完这篇,您有何感觉呢?

文章评论

共有位Admini5网友发表了评论 查看完整内容

24小时热门信息