Horje
HTML DOM Input URL focus() Method

The Input URL focus() method in HTML DOM is used to get focus to the Input URL field when the event occurs. We can use this method for directing the focus of the user when an event occurs.

Syntax:

URLObject.focus()

Parameters: This method does not contain any parameter values.

Return Value: It does not return any value.

Example: Below program illustrates the use of the input URL focus() method in HTML DOM. 

HTML

!DOCTYPE html>
<html>
  
<body style="text-align:center;">
    <h1 style="color:green">
      GeeksforGeeks
    </h1>
    <strong>DOM Input URL focus() method</strong>
    <form id="myForm">
       <input type="URL" id="url_id" name="Lnk">
    </form>
    <br>
    <button onclick="myfocus()">
      Get Focus!
    </button>
      
    <script>
        function myfocus() {
            
            // Use the focus() method on the
            // selected element
            document.getElementById("url_id").focus();
        }
    </script>
</body>
</html>

Output:

Supported Browsers:

  • Google Chrome
  • Mozilla Firefox
  • Internet Explorer
  • Opera
  • Safari



Reffered: https://www.geeksforgeeks.org


HTML

Related
HTML DOM Marquee scrollDelay Property HTML DOM Marquee scrollDelay Property
HTML DOM Input Search focus() Method HTML DOM Input Search focus() Method
HTML DOM Input Text focus() Method HTML DOM Input Text focus() Method
What are Cell Padding &amp; Cell Spacing in HTML Table ? What are Cell Padding &amp; Cell Spacing in HTML Table ?
What is the significance of adding autocomplete attribute in HTML Form ? What is the significance of adding autocomplete attribute in HTML Form ?

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
12