开发者

Test whether document.domain was explicitly set

开发者 https://www.devze.com 2023-03-31 10:04 出处:网络
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 yo

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消