My problem is that I\'m creating an application that will be added to different pages in an iframe. But sometimes it will be on my own domain and sometimes on some one elses
You could use:
try{
parent.document;
// accessible
}catch(e){
// not accessible
}
I tried checking parent document, but for some reasons in new iOS devices (chrome or safari) it didn't throw the exception, but just continued to the next step.
So I took it another step:
try{
var doc = parent.document;
if(!doc)
throw new Error('Unaccessible');
// accessible
}catch(e){
// not accessible
}