Exoon Posted January 9, 2009 Share Posted January 9, 2009 Hello, I was wondering if its possible to check if the site has been loaded in an iframe and if it has then load it up to the full page automatically. As i have a script that is counting hits in from a website like a topsite and want to stop people cheating it. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/140199-solved-stopping-a-site-from-iframing-to-me/ Share on other sites More sharing options...
bubbasheeko Posted January 9, 2009 Share Posted January 9, 2009 I had found this somewhere and have modified it, wish I could credit the original source <script language="javascript"> // DO I FEEL AN IFRAME?? try { // Alright...what is the parent window url? var parent = window.parent.location; var str = new String(parent); } catch (e) //CHECKING - IF IT IS IN AN IFRAME SHOW ERROR PAGE { window.location = 'errorpage.html'; // CREATE AN ERROR PAGE AND PUT IT IN HERE } </script> <noscript>Your browser is not javascript enabled or it has been disabled. Javascript is required to see this page.</noscript> Hope this helps! Link to comment https://forums.phpfreaks.com/topic/140199-solved-stopping-a-site-from-iframing-to-me/#findComment-733652 Share on other sites More sharing options...
Exoon Posted January 9, 2009 Author Share Posted January 9, 2009 Hey, thanks for the reply. Do you know how i could use this to open the page to a full screen, because i still want the visitor on the website i just dont want anyone putting an iframe to 1x1 or somthing thanks Link to comment https://forums.phpfreaks.com/topic/140199-solved-stopping-a-site-from-iframing-to-me/#findComment-733662 Share on other sites More sharing options...
corbin Posted January 9, 2009 Share Posted January 9, 2009 You could try doing: window.parent.location = 'http://yoursite.com/'; Link to comment https://forums.phpfreaks.com/topic/140199-solved-stopping-a-site-from-iframing-to-me/#findComment-733716 Share on other sites More sharing options...
bubbasheeko Posted January 9, 2009 Share Posted January 9, 2009 That does not work - tested that today and the parent.document setting will affect the content of the iframe only. Strange behavior considering that same tag is used to check the url of the parent page. Link to comment https://forums.phpfreaks.com/topic/140199-solved-stopping-a-site-from-iframing-to-me/#findComment-733748 Share on other sites More sharing options...
bubbasheeko Posted January 10, 2009 Share Posted January 10, 2009 Here this will just simplify it if the visitors browser has javascript enabled: <script type="text/javascript"> if (top.frames.length!=0) { if (window.location.href.replace) top.location.replace(self.location.href); else top.location.href=self.document.href; } </script> <noscript>Your browser is not javascript enabled or it has been disabled. Javascript is required to see this page.</noscript> If a frame is detected it will remove it and place your site in the parent window. Link to comment https://forums.phpfreaks.com/topic/140199-solved-stopping-a-site-from-iframing-to-me/#findComment-733795 Share on other sites More sharing options...
Exoon Posted January 10, 2009 Author Share Posted January 10, 2009 thanks, thats working great!! Link to comment https://forums.phpfreaks.com/topic/140199-solved-stopping-a-site-from-iframing-to-me/#findComment-734061 Share on other sites More sharing options...
bubbasheeko Posted January 10, 2009 Share Posted January 10, 2009 Hey Exoon, Great! Just remember to mark the thread as resolved! Link to comment https://forums.phpfreaks.com/topic/140199-solved-stopping-a-site-from-iframing-to-me/#findComment-734072 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.