OnPageNew 事件

       

在新建网页时发生。

Private Sub Application_OnPageNew(ByVal pPage As PageWindow)

pPage  必选,PageWindowEx 类型。PageWindowEx 对象。

注释

当用户在框架集中新建网页时,OnPageNew 仅会在包含框架集标记的网页打开时,对框架网页触发一次。然后 FrontPage 会执行事件程序中指定的代码。

注意  OnPageNew 事件只会为默认框架集触发,即使网页上还有其他框架。该事件只会在 FrontPage 处于“网页”视图模式时才会触发。如果 FrontPage 处于其他任何视图模式下,OnPageNew 事件都不会触发。

示例

本示例将主题应用于新网页。

注意  若要运行本示例,必须至少打开一个站点。本示例使用 Rogue Cellars 作为指定的站点,将 Zinfandel.htm 作为指定的网页。您可以创建一个称为 Rogue Cellars 的站点以及称为 Zinfandel.htm 的网页,或可用您选择的站点和网页来代替。

创建一个称为 frmLaunchEvents.frm 的表单并添加两个按钮,分别称为 cmdAddPagecmdCancel。将下列代码添加到表单代码窗口的 Declarations 部分。

Option Explicit
Private WithEvents eFPApplication As Application
Private pPage As PageWindowEx

将下列代码添加到代码窗口的 UserForm_Initialize 部分。

Private Sub UserForm_Initialize()
    Set eFPApplication = New Application
End Sub

将下列代码添加到代码窗口的 cmdAddPage_Click 部分。该代码向 PageWindows 集合添加文件并将其打开。

Private Sub cmdAddPage_Click()
    Dim myPageWindows As PageWindows
    Dim myFile As String

    Set myPageWindows = ActiveWeb.ActiveWebWindow.PageWindows
    myFile = _
        "file:///C:/My Documents/My Webs/Rogue Cellars/Zinfandel.htm"
    myPageWindows.Add (myFile)
End Sub

将下列代码添加到代码窗口的 cmdCancel_Click 部分。

Private Sub cmdCancel_Click()
    'Hide the form.
    frmLaunchEvents.Hide
    Exit Sub
End Sub

将下列代码添加到代码窗口的 eFPApplication_OnPageNew 部分。

Private Sub eFPApplication_OnPageNew(ByVal pPage As PageWindow)
    pPage.ApplyTheme ("artsy")
End Sub