Jump to content

iframe redirecting to main window


yyx748

Recommended Posts

I made my php website using iframe. U can see the pages refreshes in the same area

http://www.sgdrugstore.com

 

However, when i enter the url directly in browsers will result in this

http://www.sgdrugstore.com/prod.php

http://www.sgdrugstore.com/product.php?id=27

 

Question is how do i do some sort of checking whether the page is loaded within the iframe or not?

 

In javascript its something like this

if (self == top){
var url = self.location.pathname;
self.location = "index.php?" + url; // name of parent page
}

 

I know the concept of how to do it in php but i juz dunno how to type this line in php....how do i type this line??

self == top

 

 

This is my concept

 

In other pages

checking if its self=top

if top, create cookie

 

In home page

check if cookie exist

if exist then redirect iframe src to that cookie page

 

Anyone can help me or have any other methods?

Link to comment
https://forums.phpfreaks.com/topic/168377-iframe-redirecting-to-main-window/
Share on other sites

There isn't a way to do this in php. You're wanting to test a client side feature with a server side script. Why not instead of suing a n iframe. Have a div and use php to pull in the content and print it inside that div. That gets rid of the irfame (iframe's area nasty anyway) and will give you control over testing the page via php, you can make sure that the 'inner' page isn't getting called directly.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.