Forum Moderators: coopster

Message Too Old, No Replies

frameset page with redirects

using php to change the location of only one frame

         

RedScourge

8:04 am on Dec 7, 2004 (gmt 0)

10+ Year Member



ok, i am trying to make a frameset page like this:

3 frames, one is a chat frame with a chat script, one is a php form that takes in a URL, and changes the location of the third frame.

frames:

-webpage frame <--this one should change
-php url form frame
-chat frame

the php url form frame should accept a URL and change what is displayed in the webpage frame only.

i am stumped as to how i would do this, and using iframes is out of the question.

the thing i made just ends up that each time you submit a url to the php form script, it breaks the second frame into 2 frames, and that is definitely not what i want.

if there was a way to do this in javascript, would anyone care to tell me how i would do it or what the functions i would use are called?

jatar_k

5:18 pm on Dec 7, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



is the html generated, or sent to the browser, by the php script loading a frameset?

RedScourge

9:12 pm on Dec 7, 2004 (gmt 0)

10+ Year Member



i dont get what you asked, but well, the thing is, i have the main frameset page that defines two frames, the main page and a chat frame, the main page is going to be split by another frames page, one of which is the website frame and one is the form frame, and the form frame is supposed to somehow change the contents of the website frame.

im thinking i might have to use an iframe for this, despite REALLY not wanting to. if i did it with an iframe i would have a php script that has the form and the iframe in the main frame, and have it change the src="" portion of the iframe. the only problem with this, is that my chat screen is resizeable, and my iframe is not, once you make the iframe you cant resize it, but you can resize the chat frame (like to pull it down if you need room, etc)

RedScourge

9:17 pm on Dec 7, 2004 (gmt 0)

10+ Year Member



perhaps what i need to do is make a function in the php form file that gets a $_POST parameter if it exists, and if it does, it makes the frame source for the website frame be equal to its passed value, the passed value being a valid url.

anyone else have any other ideas?

RedScourge

9:23 pm on Dec 7, 2004 (gmt 0)

10+ Year Member



nope, still back to square one, i cant pop up out of a frame, i can do that using an <a href> with a target=_parent, but...yeah...cant pop out of a frame with a form that i know of.

ideas anyone?

jezra

10:20 pm on Dec 7, 2004 (gmt 0)

10+ Year Member



Supposing that your frames are named
"frame1" for the chat window
"frame2" for the frame that changes
"frame3" for the php frame

frame3 receives the URL variable as part of a form input using GET.
The first thing to do is retrieve the URL

<?
$newURL=$_GET['URL'];//retrieve the URL
?>

Somewhere in the html code of frame3 should be some javascript with a PHP echo of the new URL

<script language='javascript'>
top.frame2.location="<? echo $newURL;?>";
</script>

This leaves a lot of dependancy on the browsers javascript capabilities. You'll want to brush up on javascript frame usage. I believe the following will work as well, but it has been a while since I javascripted some frames.

parent.frame2.document.location.href="<? echo $newURL;?>";

bubone2

10:31 pm on Dec 7, 2004 (gmt 0)

10+ Year Member



Jezra is correct about using JavaScript here. I do something very simlar. However, he raises a good point about the browser being javascript capable. Depending on your intended audience, may be a something to think about.

I am making the assumption that the frame structure you have is one along the top, left side, and a main frame for the primary content.

I would do a form in the page in which you are selecting what page you want to jump to. Then use the $_POST to grab your variable. But here is how you do it (to solidify what Jezra said):

$selected_page = $_POST['selected_page'];
$SUBMIT = $_POST['SUBMIT'];

if($SUBMIT)
{ <script language=javascript>
parent.leftFrame.location="menu.php";
parent.mainFrame.location="$selected_page";
</script
}

//HTML part

<html>
<body>
<form method=POST>
// input for name selection (<select> or textbox etc)
<input type=submit name=SUBMIT value="Go to Page">
</form>
</body>
</html>

The leftFrame and mainFrame correspond to the frame name (which you must set in your index page (it is an attribute of <frame> which is inside your <frameset> tags). By the way, you may notice that I do not use generic names like frame1 and frame2 ... be specific (for your own benefit). The example above would affect two frames. You can only affect one at a time if you wish (which is what it sounds like you want to do).

Josh

AndyD

11:39 pm on Dec 7, 2004 (gmt 0)

10+ Year Member



Can I ask a question related too this...

I have a page with 2 iframes in. Once my php script has process in one of the iframes, I need to re-display the original page. How do I do this without it opening another fresh window (using target=).

Should I be using parent.location= or something similar?

Andrew

RedScourge

10:05 am on Dec 8, 2004 (gmt 0)

10+ Year Member



i found a simple solution finally!

<FORM METHOD="POST" ACTION="navform2.php" target="_parent">

the navform2.php page all it does is passes a Header("Location: [#*$!.xxx.xxx.xxx:8088...]

which goes to chatnav, which is the frameset of the viewing window and the navform2 window, and the fact that the navform2 has a target="_parent" (i didnt knowi could do this! took for ever to find this out!) means that what will happen is exactly what i want to happen.

chatnav is a frameset page that can accept a $_GET parameter that is a url and displays that URL in the URL frame that was entered in the navform2 frame, and target=_parent works because the chat frame itself is not overwritten by _parent, so all is well!

if anyone wants my for this if theyre interested gimme a shout