Skip to content
Related Articles
Open in App
Not now

Related Articles

HTML DOM Window origin Property

Improve Article
Save Article
  • Last Updated : 29 Jul, 2020
Improve Article
Save Article

The window origin property returns the origin of the global scope, serialized as a string of the window.


var origin = self.origin;

Return Value: A string containing the origin.

Example: This example shows how to get the origin of the document using this property.


<body style="text-align:center;">
    <h1 style="color:green;">
        HTML | origin property
    <button onclick="Geeks()">
        Click Here
    <p id="a"></p>
        var a = document.getElementById("a");
        function Geeks() {
            a.innerHTML = "document origin is : "
                    + self.origin;


Before Clicking the Button:

After Clicking the Button: 

Note: If the origin is not a scheme/host/port tuple (say you are trying to run it locally, i.e. via file:// URL), the origin property will return the string “null”.

Supported Browsers:

  • Google Chrome
  • Edge
  • Firefox
  • Safari
  • Opera
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!