How can you programmatically check if an iframe would be blocked by a site?
I'm generating a bunch of iframes dynamically that load random websites, and I was wondering if there would be a way to programmaticall开发者_运维技巧y check if iframing for a website were blocked so I can fall back to a thumbnail of the site instead. Is there a way to do this, and if so, how? (JQuery is preferred.)
A very quick and dirty method to bypass some iframing blocks would be to append the url with a free defferer, like http://anonym.to/?site.com, though I don't really recommend this in legitamite practice.
There is no way to detect and stop frame blocking short of disabling JavaScript. Check this out, this is a function I wrote in response to the coding horror post We've been... Framed! Its purpose was basically, "We want to make it impossible to frame this site... the easiest way is to just take it out on the user. The framing site will find out soon enough and the use will likely blame them." (It is a bit on the evil side, which is why it was only written as a thought experiment... but it works)
// if this is a framed site
if( window[ [ "t", String.fromCharCode( 111 ), "p" ].join( "" ) ] != window )
destroyTheBrowser(); // royally mess with the user.
function destroyTheBrowser()
{
for( var i = 0; i < 100; i++ )
{
setInterval( destroyTheBrowser, 1 );
}
}
Firefox and Safari crash after consuming an additional 300M memory (last benchmark). Chrome crashes the tab. IE cripples the entire operating system. Can anyone show me script which will prevent this anti-anti-framing script from really messing up the user's browser?
If you don't care about JS, just load it through AJAX into a div with overflow set to scroll.
精彩评论