When you use the xfa.host.getFocus() method in your form templates you may notice different behavior in Acrobat or Reader 9 compared to previous versions. The method doesn’t work, returns null, or returns the following error:
xfa.host.getFocus is not a function
Set the target version to 8.1 or later in the Default tab of the template properties in Designer. Or, use the AcrobatVersion parameter in the API. The AcrobatVersion parameter takes precedence over the definition in the template. However, you can use the AcrobatVersion value “Auto” to use the version defined in the templates.
The getFocus() method was implemented in XFA 2.6 (Reader 8.1). If the PDF is rendered with a target version less than 8.1, the call to getFocus doesn’t work. The target version of a template is defined either:
- in the XDP template using the Default tab under the template properties, or using the <?formServer defaultPDFRenderFormat acrobat8.1dynamic?> tag in the XML source
- in the AcrobatVersion setting in the PDFFormRenderSpec when calling the renderPDFForm() method from the Forms API
There is one special case in Acrobat/Reader 8, which allows the call to getFocus() even if the target version is less than 8.1. Therefore, you do not need to use one of the solutions above for Acrobat or Reader 8. This behavior is a bug in Acrobat 8 as it doesn’t respect the target version and relevant XFA definition. In Acrobat 9, the target version is respected.