Solved

Transferring long CGI input values to frame, from frameset

Posted on 2013-01-31
9
986 Views
Last Modified: 2013-12-25
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?
0
Comment
Question by:stefanlennerbrant
  • 4
  • 3
9 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 38845662
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&
0
 

Author Comment

by:stefanlennerbrant
ID: 38865430
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?
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 38865478
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&
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:stefanlennerbrant
ID: 38867551
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)
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 500 total points
ID: 38868669
most probably has been investigated by thousands of developers over the years

If that was the case and there was any solution of value there would be multiple websites promoting the solution to try and make a buck.  In the absence of that, the logical mind must assume the you are out in an empty field; no where near a main road.

Frames were abandoned many years ago. Even before HTML5 these kind of requirements were solved with XMLHTTP (later known as AJAX) to populate any number of different element types by progressive developers who did not limited themselves by applying constraints from the 20th century.

If you search it is possible you will find some old hack written 8 or ten years ago.
 Cd&
0
 

Author Comment

by:stefanlennerbrant
ID: 38874855
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.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 38877041
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&
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now