frame (and javascript) in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
veronica12
Forum Newbie
Posts: 6
Joined: Fri May 04, 2007 4:30 pm

frame (and javascript) in PHP

Post by veronica12 »

Weirdan | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi to everybody.
Suppose to have a HTML page with 2 column-frames:
[syntax="html"]
<FRAMESET cols="40%, 60%">
<FRAME src="left.html"    id="frame_left"  name="frame_left">
<FRAME src="right.html"   id="frame_right" name="frame_right">
</NOFRAMES> 
in the left frame I put a form, with e.g. a textarea and with the action linking to some "client_side_file.html" that will be loaded in the right frame

Code: Select all

<form name="form1" action="client_side_file.html"
                   enctype="multipart/form-data"
                   method="post"
                   onsubmit="return checkInput()"
                  TARGET="frame_right">

    <textarea cols="40" rows="10" READONLY name="LOG_txtArea" WRAP=OFF></textarea> 
where "client_side_file.html" is just a "click me" link that add text to the textarea in the left frame:

Code: Select all

<HTML> <HEAD><SCRIPT type="text/javascript">
<!--
function log_in_left_frame (text) {
    parent.frame_left.document.form1.LOG_txtArea.value += text;
}
// -->
</SCRIPT></HEAD><BODY>
<a href onClick="log_in_left_frame('blablabla')">click me</a>
</BODY></HTML>

ALL WORKS FINE!


Now, where is my bug if I only :
1/2 : change action="client_side_file.html with action="http:.....php"
2/2 : make http:.....php code so that it returns from the server an exact copy of the file client_side_file.html

I would expect the same behaviour (while this way it doesn't work) ??????!!!!!!!

Why when the file is returned by PHP from the server there is no way to access the hierarchy context (e.g. right/left frame and their parent) ?

Is it really impossible ? Is there any trick to go round in another way ?

Thank you.


Weirdan | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

if you want to mess with other frames, you'll have to do it on the client side (i.e. javascript).
User avatar
arturm
Forum Commoner
Posts: 86
Joined: Fri Apr 13, 2007 8:29 am
Location: NY
Contact:

Post by arturm »

there has to be somethig wrong with your code in the php file
I would recommend you to use firefox with Web Developer tool installed - it has very good debuging tool for javascript

there is no difference between javascript in html and javascript generated in php (of course if you generate it properly)

show us your PHP file.
veronica12
Forum Newbie
Posts: 6
Joined: Fri May 04, 2007 4:30 pm

Post by veronica12 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Thanks for the hint!
I use Firefox (IE only to then check portability) but "Web Developer tool" has been a nice advice.
Well, my PHP approach was really simple [i](maybe to much)[/i] as I only added some [b]echo [/b] to the [i]client_side_file.html [/i].

Here it is the complete PHP file

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML> <HEAD>

<?php
    echo ("<SCRIPT type=\"text/javascript\">\n");
    echo ("<!--\n");
    echo ("function log_in_left_frame (text) {\n");
    echo ("parent.frame_left.document.form1.LOG_txtArea.value = text;\n");
    echo ("}\n");
    echo ("// -->\n");
    echo ("</SCRIPT>\n");
?>
</HEAD><BODY>
<?php
   echo ("<a href onClick=\"log_in_left_frame('blablabla')\">click me</a>");
?>
</BODY></HTML>
I'm quite a newbie to PHP and I think there are still some big misunderstanding in my approach.
Thanks


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
veronica12
Forum Newbie
Posts: 6
Joined: Fri May 04, 2007 4:30 pm

Post by veronica12 »

Well, an even easier way to test the matter can be just to copy the client_side_file.html on the server and substitute the .html extension with .php. The effect is the same, that is the javascript code when returned from the server stops to work on the DOM hierarchy.....
veronica12
Forum Newbie
Posts: 6
Joined: Fri May 04, 2007 4:30 pm

Post by veronica12 »

I share what I found to be a final word on this:
http://msdn.microsoft.com/workshop/auth ... curity.asp

I found this investigating my error console msg:
"Error: uncaught exception: Permission denied to get property HTMLDocument.form1"
where the "permissin denied" sounds a good hint.
Post Reply