HTML DOM इनपुट URL ऑटोफोकस प्रॉपर्टी सेट/रिटर्न करती है कि इनपुट URL प्रारंभिक पेज लोड पर केंद्रित है या नहीं।
सिंटैक्स
निम्नलिखित वाक्य रचना है -
- बूलियन मान लौटाना - सही/गलत
inputURLObject.autofocus
- ऑटोफोकस को बूलियनवैल्यू पर सेट करना
inputURLObject.autofocus = booleanValue
बूलियन मान
यहां, “बूलियनवैल्यू” निम्नलिखित हो सकते हैं -
| booleanValue | <वें शैली ="चौड़ाई:82.8571%; पाठ-संरेखण:केंद्र;">विवरणवें>|
|---|---|
| सत्य | यह परिभाषित करता है कि पेज लोड होने पर इनपुट ऑटोफोकस हो जाएगा। |
| गलत | यह डिफ़ॉल्ट मान है और इनपुट ऑटोफोकस्ड नहीं है। |
उदाहरण
आइए इनपुट URL ऑटोफोकस का एक उदाहरण देखें संपत्ति -
<!DOCTYPE html>
<html>
<head>
<title>Input URL autofocus</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
}
input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>URL-autofocus</legend>
<label for="URLSelect">URL :
<input type="url" id="URLSelect" placeholder="https://www.google.com" autofocus>
</label>
<input type="button" onclick="removeAutofocus()" value="Remove Autofocus">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputURL = document.getElementById("URLSelect");
divDisplay.textContent = 'Autofocus: '+inputURL.autofocus;
function removeAutofocus() {
inputURL.autofocus = false;
divDisplay.textContent = 'Autofocus: '+inputURL.autofocus;
}
</script>
</body>
</html> आउटपुट
यह निम्नलिखित आउटपुट देगा -
'ऑटोफोकस निकालें' clicking क्लिक करने से पहले बटन -

‘ऑटोफोकस निकालें’ . क्लिक करने के बाद बटन -
