User Tools

Site Tools


public:html_variables_js

HTML: how to output variables


<script>
      function printVar() {
          const origin = window.location.origin;
          document.write(`${origin}`);
      }
      printVar();
</script>

1. Get the full URL:                      window.location
2. Get the only protocol:                 window.location.protocol
3. Get the host (without port):           window.location.hostname
4. Get the host + port:                   window.location.host
5. Get the host and protocol:             window.location.origin


return to gimbo wiki home page

public/html_variables_js.txt · Last modified: by gmarco