Share via


onbeforeunload Event

Occurs before unloading a page in Microsoft FrontPage.

expression.onbeforeunload

*expression   * Required. An expression that returns one of the objects in the Applies To list, which has been declared using the WithEvents keyword in a class module.

Example

The following example displays a message if the active document has been modified since it was last saved, and then saves the document at the user's request. This example must be placed in a class module, and it assumes that you have declared in the General Declarations section of a class module an FPHTMLWindow2 object variable called "objWindow" using the WithEvents keyword.

Private Sub objWindow_onbeforeunload()
    Dim intResponse As Integer
    Dim objDoc As FPHTMLDocument
    
    Set objDoc = objWindow.Document
    
    If objDoc.IsDirty = True Then
        intResponse = MsgBox("Do you want to save " & _
            "the page before you close it?", vbYesNo)
            
        If intResponse = vbYes Then
            objDoc.Save False
        End If
    End If
End Sub

Applies to | FPHTMLBody Object | FPHTMLFrameSetSite Object | FPHTMLWindow2 Object | FPHTMLWindowProxy Object | IHTMLBodyElement Object | IHTMLFrameSetElement Object | IHTMLWindow2 Object