try { if (top.location.hostname != self.location.hostname) throw 1; } catch (e) { top.location.href = self.location.href; } This is an example