HTML DOM Input URL select() Method
Last Updated :
26 Aug, 2022
Improve
The HTML <input type=”url”> is used to define a field that entered a URL. This input value is automatically validated before submitting the form.
The input URL select() method in HTML DOM is used to select the content of a URL text field. It is an in-built method of input URL Object. Refer to components of a URL from the given link
Approach: Blue background color is added to the content of the URL when the user clicks on the button to show that it's selected.
Syntax:
URLObject.select()
- Parameters: It does not accept any parameter.
- Return Value: It does not return any value.
Example: This example uses the input URL select() method to select the content inside the URL Field.
<!DOCTYPE html>
<html>
<head>
<title> DOM Input URL select() Method </title>
</head>
<body>
<center>
<h1 style="color:green;">GeeksforGeeks</h1>
<h2>DOM Input URL select() Method </h2>
<label for="uname" style="color:green">
<b>Enter URL</b>
</label>
<input type="url" id="inputID" placeholder="Enter URL"
value="https://www.geeksforgeeks.org/">
<br>
<br>
<button type="button" onclick="selectURLMethod()">
Click
</button>
<script>
function selectURLMethod() {
document.getElementById("inputID").select();
}
</script>
</center>
</body>
</html>
Output:

Supported Browsers: The list of browsers supported by HTML DOM Input URL select() Method are listed below:-
- Google Chrome 1
- Edge 12
- Firefox
- Safari
- Opera 11