W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2012

[whatwg] proposal for a location.domain property

From: Hallvord R. M. Steen <hallvord@opera.com>
Date: Thu, 24 May 2012 17:35:49 +0200
To: "whatwg@whatwg.org" <whatwg@whatwg.org>
Message-ID: <op.wetj9zb0a3v5gv@hr-desk>
Many browser engines use lists of top-level domains to be able to  
determine what a server's "base domain" is. For some use cases it would be  
interesting to have this information available to scripts. I list some use  
cases I can think of below:

1) Determining in a simple and fool-proof manner that a page is from a  
given domain. For example, if a script that might run on *.example.com,  
*.example.co.uk etc can do
if(location.domain.indexOf('example.'==0) to check whether it runs on an  
*.example.* site (and not get a false positive match on  

2) Checking what the shortest possible string for document.domain is.

3) Set cookies for all servers in a domain easily from JS without specific  
string operations on the hostname

Hallvord R. M. Steen
Core tester, Opera Software
Received on Thursday, 24 May 2012 15:40:22 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:42 UTC