Search code examples
javascriptjquerydocumentsame-origin-policy

jQuery - if exists, get value of document.domain


How to check if document.domain is set on a page, and return it's value?

Update

before the barrage of negativity, I was inquiring about how to get the document.domain value when it's been explicitly set.

What I ended up with was

if(window.location.hostname !== document.domain)

this will tell you if document.domain has been set explicitly on a page.


Solution

  • if(window.location.hostname !== document.domain)
    

    Is how to check if document.domain is being explicitly set - by comparing the document.domain variable against the hostname, if the above returns as true, then document.domain is being reassigned on the page.