Test whether document.domain was explicitly set
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:
do开发者_C百科cument.domain = document.domain;
But is there a way to programmatically tell the difference?
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.
精彩评论