Link to home
Start Free TrialLog in
Avatar of Stefan Lennerbrant
Stefan LennerbrantFlag for Sweden

asked on

Transferring long CGI input values to frame, from frameset

I've got a page that uses a frameset to display two frames.
All pages (frameset+frames) are created dynamically by CGI scripts (applications)

The user of course requests only the frameset page (created by CGI script "begin.exe") , and then gets a page that contains:
<frameset cols="500,1*">
  <frame src="oneframe.exe">
  <frame src="otherframe.exe">
</frameset>

However, the user may supply a parameter, using a link:
  http://server/begin.exe?MYDATA=someinformation

This parameter data must be passed on to the "oneframe.exe" CGI script, as it is used as input to create that frame html page.


The obvious solution is to let begin.exe insert the data in the <frame> line:
  <frame src="oneframe.exe?MYDATA=someinformation">

but the problem is that this value may be very long, thousands of characters (the request  to begin.exe is done with POST)

And as far as I know, I cannot let a frameset use POST to access a frame, it always uses GET? Correct?


The only solution that I have come up with, is to create a (static) html page "tranfer_to_oneframe.htm" that uses javascript to collect information from the frameset (which of course is the frame's parent window) and then populates a hidden form in this static html page. This is then submitted to "oneframe.exe" using POST.

It seems like a <form> cannot exist on the frameset page, so I use javascript variables.

The frameset file (created by begin.exe) then looks like this:

<script>
var varMYDATA='someinformation';
</script>
<frameset cols="500,1*">
  <frame src="transfer_to_oneframe.htm">
  <frame src="otherframe.exe">
</frameset>

The transfer_to_oneframe.html (static file) looks like this:

<form name=TransferForm method=POST action="oneframe.exe">
<input type=hidden name=MYDATA>
</form>
<script>
 if(window.parent && window.parent.varMYDATA) {
   document.TransferForm.MYDATA.value = window.parent.varMYDATA;
   document.TransferForm.submit();
 }
</script>


This seems to work OK, but is it the recommended solution?
I cannot use cookies to transfer the data, so that method is not available.
Also, I cannot store data in a database on the server and then pass only some (short) database record identifier to the oneframe.exe script

The question is: Are there any better alternatives?
Are there any downsides to the above solution?
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Frames and frameset are very much 20th century approaches.  They have been dropped in HTML5.  You might have an easier time of it using iframes which can be much more dynamically managed, and are an integrated part of the main page, even though they get their content from a different source.  While you may not be able to use cookies, you should be able to use sessions.


Cd&
Avatar of Stefan Lennerbrant

ASKER

Sessions? You mean like when using php and such?
No, there are no sessions onvolved here, only plain html.

Frames may be 20th century, but still that is what is being used here.

So the question remains.
The above solution, which seems to work very well, is that not recommended for any reason?
And are there other alternatives (while still using frames and no sessions etc) that I should test instead?
You have applied a set of constraints that precludes any method being used except the preferred method you have adopted so:

The above solution, which seems to work very well, is that not recommended for any reason?
It is not recommended because it is obsolete, and no longer support in the latest standards; at some point some browsers may drop support for it.

And are there other alternatives (while still using frames and no sessions etc) that I should test instead?
Obviously the question has been asked with requirements and limits that dictates support for the current method; and I would never give such confirmation because it is bad practice and bad design

Cd&
With all due respect, I'd say that using frames is a setup that is still to be considered valid., for a long time to come. Regardless of HTML5 :-)
I do agree with you in principle, but that doesn't help much in the actual situation.

In particular, this problem (getting input to a frameset page, that must be passed on to one of the underlying frame pages), must be something that many developers have been working on, over the years (and especially before, when frames were the main setup)


The obvious solution (I'd say) would be to store the input in a database and pass a recod ID to the frame page (that would more or less be the session method, right?)

Well, yes, that solution is of course something that could be implemented, it's not very complicated. I shouldn't have said that it was of of the question (if I said that?)

However, using a <form> in the frameset page, or javascript variables, or something else that can be transferred to or accessed by the frame, would be a very much cleaner way of implementing the data transfer.

And as this "problem", passing data to a frame during page loading, most probably has been investigated by thousands of developers over the years, I was thinking that maybe some of them had experience with how to actually solve the problem at hand.
(and again, this is not php or asp or any other framwork that automatically implements session functionality)
ASKER CERTIFIED SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Well, then, the method I proposed (which seems to work well) seems to be the solution to the setup, to get a frame populated with (long value) data passed as input to the frameset.
If a 20th century method works for you and you want to use it... go right ahead.  Last time I checked, it was not necessary to have a permit for obsolete technology.

Cd&