स्थान मूल गुण URL के प्रोटोकॉल, होस्टनाम, होस्ट पोर्ट नंबर (यदि निर्दिष्ट हो) के अनुरूप स्ट्रिंग लौटाता है।
सिंटैक्स
निम्नलिखित वाक्य रचना है -
मूल . का रिटर्निंग मान संपत्ति
location.origin
उदाहरण
आइए स्थान मूल . के लिए एक उदाहरण देखें संपत्ति -
<!DOCTYPE html>
<html>
<head>
<title>Location origin</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>Location-origin</legend>
<label for="urlSelect">Current URL:</label>
<input type="url" size="30" id="urlSelect" value="https://www.example.com:2544/aboutUs">
<input type="button" onclick="getorigin()" value="Get origin">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var urlSelect = document.getElementById("urlSelect");
function getorigin(){
divDisplay.textContent = 'URL Origin: '+location.origin;
}
</script>
</body>
</html> आउटपुट
यह निम्नलिखित आउटपुट देगा -
‘उत्पत्ति प्राप्त करें’ . क्लिक करने से पहले बटन -

‘उत्पत्ति प्राप्त करें’ . क्लिक करने के बाद बटन -
