Frame/form question

D

Dfenestr8

Hi.

I'm trying to build a page that has two frames, both of which are
generated by a different cgi script.

The lower frame is generated by a script called "control.py".

The upper frame is generated by a script called "getchat.py".

On the lower frame, there is a button called "REFRESH". When clicked, I
want it to be able to read information in a hidden input on a form in the
upper frame, that being .....

<input type=hidden NAME="last_seen" value = "' + str(lastByteLoc) + '">

.... and submit that information to getchat.py.

I have a javascript routine worked out which *usually* does that when I
view the page with konqueror. Unfortunately it never seems to work with
mozilla. Can anybody tell me why? And better still, how I can fix it?

Here's the code generated by control.py ......

In the <head> i have ....

<script language = "javascript">
<!-- hide from older browsers

function refreshPosts()
{
plast = parent.chatframe.form1.last_seen.value;
parent.chatframe.location = 'getchat.py?last_seen=' + plast
}

//-->
</script>

And on the form in the lower frame, I have this input ......

<input type = "button" value = "REFRESH" onClick = "refreshPosts()">

Thanx in advance.
 
K

kaeli

function refreshPosts()
{
plast = parent.chatframe.form1.last_seen.value;

parent.chatframe is a window object. Form belongs to document.

plast = parent.chatframe.document.form1.last_seen.value;

--
 
L

Lasse Reichstein Nielsen

kaeli said:
parent.chatframe is a window object. Form belongs to document.

plast = parent.chatframe.document.form1.last_seen.value;

or better yet (since I prefer to use the appropriate collections :)

plast = parent.frames['chatframe'].document.forms['form1'].
elements['last_seen'].value;

There is no official standard for Javascript access to frames,
so I can't say that using the frames collection is more official than
just assuming the frames are direct properties of their parent.

However, the W3C DOM specification requires the forms collection, and
there is no requirement that forms are available as properties of the
document element. That means that a (hypothetical) strictly standards
adhering browser (implementing nothing unofficial) will only work
using the forms collection.

Ditto for the elements collection.

/L
 
D

Dfenestr8

parent.chatframe is a window object. Form belongs to document.

plast = parent.chatframe.document.form1.last_seen.value;

Thanx. That does the job.

Now it works perfectly with mozilla but sometimes breaks when using
Konqueror. Specifically, when I press REFRESH, but there's nothing new to
update the chatframe with. After that, REFRESH won't work again until I
reload the whole page.
 
K

kaeli

Thanx. That does the job.

Now it works perfectly with mozilla but sometimes breaks when using
Konqueror. Specifically, when I press REFRESH, but there's nothing new to
update the chatframe with. After that, REFRESH won't work again until I
reload the whole page.

See Lasse's response - Konqueror may need the full reference instead of
the shortcut I'm used to (I do mostly intranet apps and only have to
deal with NN/IE).

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top