Have the text cursor placed in first text box

Is there a way with JavaScript to have the text cursor placed in the first text box when opening an html window in a macro?

Or should I use a click action?

Perhaps fire a .focus() method on your chosen textbox from a window.onload event ?

Expand disclosure triangle to view HTML source
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Focus with JavaScript</title>
    <script>
        window.onload = () =>
            document.getElementById('secondBox').focus();
    </script>
</head>
<body>
    <input type="text" placeholder="First Box" id="firstBox">
    <input type="text" placeholder="Second Box" id="secondBox">
    <input type="text" placeholder="Third Box" id="thirdBox">
</body>
</html>
2 Likes