Created
November 12, 2011 07:43
-
-
Save NuarHaruha/1360205 to your computer and use it in GitHub Desktop.
Safely break out of an iframe for blogspot/blogger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** | |
Safely break out of an iframe for blogspot.com | |
@author Nuar H. Noah | |
*/ | |
var myblog = { hostname: top.location.hostname, whitelist: Array() } | |
myblog.breakfree = function(){ | |
if (top.location != self.location) { | |
var curDomain = this.hostname.split('.')[1]; | |
this.whitelist['blogspot'] = 1; | |
this.whitelist['blogger'] = 1; // Blogspot template design preview | |
this.whitelist['google'] = 1; // Google serviceses - translate cached | |
if ( ! this.whitelist[curDomain] ) { | |
top.location = self.location.href; | |
} | |
} | |
} | |
myblog.breakfree(); | |
delete window.myblog; // gc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
xml safe escape..
if u want to post directly to blogspot template you'll need to replace the single quote
'
character with'
----
this.whitelist['blogspot'] = 1;