How to add PHP to break whole site out of a Frame.

sturgjoh - July 16, 2007 - 08:42

Hi,

First post to the forums, so be really grateful for some help!

I'm really pleased with my first drupal site: http://www.thetrack.org.uk/

but one of the places that visitors can navigate from places my site within a frame, that displays a banner above the main content.

This looks ugly (see http://www.scriptureunion.org.uk/thetrack/) and also messes up the site, as I don't seem to be able to login when the site is within a frame.

Please can I have some help with breaking out! I have tried:

<script LANGUAGE="JavaScript">
<!-- Begin
if (window != top) top.location.href = location.href;// End -->
  </script>

and also tried:

<?php if (strpos('oldpage.com',$_SERVER['HTTP_REFERER'])) { header("Location:http://mynewpage.com"); } ?>
which I tried adding to index.php in the root of my site.

This failed saying more than one program had tried to write the header, which I assumed to be the html header, which bootstrap.inc tried to write.

Anyway, my knowledge of PHP is not good enough to write some code that works, so please can I ask for help.

Thanks in advance.

John

At first glance your

Christefano - July 16, 2007 - 09:02

At first glance your JavaScript looks like it should work.

Have you already tried and decided against using the frameprevention module?

Frame prevention module

sturgjoh - July 16, 2007 - 09:08

Thanks christefano.

I will try that module now. Didn't know it existed.

Thanks

John

IT WORKED..... So case closed!

sturgjoh - July 16, 2007 - 09:12

Thanks Christefano.

Frameprevention module worked a treat.

Me now happy again!

Cheers

John

Fantastic!

Christefano - July 16, 2007 - 10:06

Fantastic!

Frame Prevention Module Crashed my site - CASE OPEN AGAIN!

sturgjoh - July 19, 2007 - 11:17

Hi Christefano,

Sorry to do a complete turnaround, but the module apeared to work and then when came back in, I had problems.
I guess I was too easily pleased!

I tried to figure out what was going on, but failed to do so, as my programming skills are not good enough.

I did post a support request http://drupal.org/node/159674 but as of yet have not had a reply, so i'm back here.

Fatal error: Call to undefined function: drupal_get_path_alias() in /home/sturgjoh/public_html/thetrack.org.uk/modules/frameprevention/frameprevention.module on line 85

Please can someone suggest what to do next.

thanks

John

P.S. Could this be to do with my .htaccess file, as the site is in a subdirectory from the html_public folder.

I think you're all gonna hate me!

sturgjoh - July 19, 2007 - 15:32

I have got around the frame thing, but asking the referal site, to not refer me into to a frame, so I think the problem is solved.

Thanks (for putting up with me)!

John

 
 

Drupal is a registered trademark of Dries Buytaert.