2

Is it possible to tell, using JavaScript, whether the document.domain property was explicitly set? Some browsers, like Firefox, distinguish between the case where it wasn't set, and the case where you call:

document.domain = document.domain;

But is there a way to programmatically tell the difference?

JW.
  • 49,102
  • 33
  • 113
  • 138
  • See http://stackoverflow.com/questions/1481251/what-does-document-domain-document-domain-do – JW. Aug 26 '11 at 05:21

1 Answers1

1

as far as I know- you can not do what you're wanting to do natively. You may be able to save document.domain to a variable at the start of your page, then check against that value to see if that has changed:

var dd = document.domain;

function isDDnatural() {
    if(dd == document.domain) return true;
    return false;
}

window.onload = function() {
    // pretending a lot is going on here
    console.log(isDDnatural()); // this will return false if the document.domain had changed
}

Just an idea.

Jacksonkr
  • 30,630
  • 38
  • 174
  • 276
  • But if you've called `document.domain = document.domain`, that will still return true. – JW. Aug 26 '11 at 16:12
  • I was just giving an idea. I hoped that others would chime in. It's too bad that won't work for you. Best of luck. – Jacksonkr Aug 28 '11 at 20:23