alt Property

Microsoft FrontPage Visual Basic

alt Property

Sets or returns a String that represents the text to display as an alternative to a graphic.

expression.alt

expression    Required. An expression that returns one of the objects in the Applies To list.

Remarks

The alt property sets or returns the text corresponding to the alt attribute of an IMG element. The text is used to replace the graphic for text-only browsers, to display in the window before the graphic has loaded, and to act as a ToolTip when the user rests the mouse pointer on the graphic.

Example

The following example returns a Boolean that indicates whether all IMG elements in the specified document have text assigned to the alt attribute.

    Function AllImagesHaveAltText(objDoc As FPHTMLDocument) As Boolean
    Dim objImages As IHTMLElementCollection
    Dim objImg As IHTMLElement
    Dim intCount As Integer
    Dim blnAlt As Boolean
    
    Set objImages = objDoc.images
    
    If objImages.Length > 0 Then
        For intCount = 0 To objImages.Length - 1
            Set objImg = objImages.Item(intCount)
            If objImg.alt = "" Then
                blnAlt = False
                Exit For
            Else
                blnAlt = True
            End If
        Next
    Else
        blnAlt = True
    End If
    
    AllImagesHaveAltText = blnAlt
End Function
  

Use the following example to call the preceding function.

    Sub CallAllImagesHaveAltText()
    MsgBox AllImagesHaveAltText(ActiveDocument)
End Sub