Monday, August 16, 2010

PHP page as sort of IFrame

Sometimes when your page needs a menu across the top of the page and a number of web pages that perform different function, a standard way is to set the main page as frames or use iframes.

I have a different way of doing the same thing using PHP. The main page itself contains the menu. The menu should be at the top of the page. When you click on it then you submit a dummy form with a variable defining the action. The php code then uses a "Switch" function to determine which web page to "include". When the page loads your web page will appear inside the main page as if it is iframe yet remains part of the main page.

Doing this has advantages.

1. Session information always stays with the main page.

2. Javascript does not need the parent child relationship. It can call functions both ways.

3. You need not define a target frame when submitting the form.

4. The sub pages need not have the full web page header. Just what ever that is need to show the content.

5. You can have the footer residing in the main page. That is somthing frames cannot do.

6. You are not bothered by the iframe size issue and there will not be any multiple scroll bars to uglify your page.

Disadvantages

1. The main page keeps reloading itself everytime you submits a form.

2. You must always have an input that defines the menu action in your form so that the same page will load when submitted. A way out is to define a session variable that defines the menu action.

No comments:

Post a Comment