Solved

CGI that opens new, small top window

Posted on 2004-09-10
10
304 Views
Last Modified: 2013-12-25
This may not be the right area to ask this question, if not, point me to the right one.

Our site has a huge archive of past issues of a daily web page (20 times a month)...1998-2004. I want to scrap the static index.html pages to the pages  and instead dynamically build the index to the past issues with two small options pulldowns for the user: Year and Month , which then are passed to a CGI... the CGI checks the directories for that year/month and builds a small set of links for the days when the page was posted, poke these into a small html template file and then send back to the client a small list of all the issues on line in the archives for that month. Actually, that is all a piece of cake... Easy enough...

but is it possible for the CGI to tell  the browser to open a new top window with a smaller rect? instead of simply taking over the current window? I want the index page to the past issues to in a small window in top of the window they were viewing. If they dismiss the index... they drop back to the window they were in.  the browser window from which the CGI call was POSTed, remains there, in the back, unchanged.  Of course I know about  java popupwindow functions, and for links "target="_blank"  but what I think i need is some preloading directive that would be in the http header, so that the browser know, hey open a new top window with this rect...  is that possible?

Sivakatirswami

<links deleted by COBOLdinosaur>
0
Comment
Question by:Sivakatirswami
  • 4
  • 4
10 Comments
 
LVL 4

Expert Comment

by:Neil_Simpson
Comment Utility
I don't think that the CGI could open a new window directly BUT you could open it with Javascript and pass the url as blah.cgi?month=12&year=2003 which would allow the CGI script to return it's value into the new window. If the field is blank it could return <script>window.close;</script> or something similar.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
Yoiu might want to use an iframe instead.  They can be hidden and re-sized dynamically, and all that would be required on the main page is the tag:
<iframe name="XX" height="1" width="1" src=""></iframe>
Then you can use target="XX" in the form or in links for any thing you want load there.

The height and width of 1 evvective make it invisible until needed and all you have to do to bring it up is when you generate the body tag of the links page do this:
<body onload="resizeTo(400,200)">

Or yo can do it in script form the main page with:
top.frames['XX].resizeTo(400,200)

Cd&
0
 

Author Comment

by:Sivakatirswami
Comment Utility
Cd&

Fascinating... I never knew about iFrames.   so I may need a little more to fill in the  gaps for implementation.


 I have the option pull downs  in a little form Year Month, submit POST action to buildIndex.cgi in a side bar column in between other links above and below.  just underneath the submit button i would insert

<iframe name="XX" height="1" width="1" src="">##I presume the html chunk would go here?## </iframe>

as you have suggested.

How do  I get the html chunk which I presume it is a complete html doc, since it has the body onload="resizeTo(400,200)">
?)  to use target ="XX"

Thank you!
Sivakatirswami

0
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
You just do the iframe this way:
<iframe name="XX" height="1" width="1" src=""></iframe>
The content HTML gets generated by buildindex.cgi as the response page.

The form tage would look like this:
<form method="post" action="buildindex.cgi" target="XX">

That tells the browser to load the response back from the script into the iframe.

It means minimum coding on the page to implement.  I assume that buildindex.cgi is already returning a response page so you just have to change the generation of the body tag to set the sizing.

Cd&


0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:Sivakatirswami
Comment Utility
Sorry about the links... I didn't realize that... no problem, won't do it again..

OK... your guidance is clear... Thanks

Yes the CGI does return the response page...  Let me play with this and then get back to you in a day or so..

I look up iFrames in w3schools.com and the warning about older browsers not seeing anything ....  is there a compatibility chart for iFrames somewhere on the net?

Sivakatirswami
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
The older browsers referred to are Netscrap 4 and earlier.  If you look at yur server logs you will probably find that your users do not use anything that old.  if you do ahve to support back that far, you are proabaly going to run into issues with Netscrap 4 no matter what approach you take.

Cd&
0
 

Author Comment

by:Sivakatirswami
Comment Utility
Aloha, CobolD:

I implemented your  proposal as best I could .... but

<iframe name="archiveIndex" height="1" width="1" src=""></iframe>

<form method="post" action="buildindex.cgi" target="archiveIndex">

with the opening of the response from the cgi as:

<body onload="resizeTo(400,200)"> ## list of links here </body>  ## which is returned by the cgi

causes the entire top-main window to resize... and the embedded iFrame does not expand at all (firefox 9 on mac, latest safari on mac)

If I do this:

<iframe name="archiveIndex" height="120" width="140" src=""></iframe>

<form method="post" action="buildindex.cgi" target="archiveIndex">

The same thing happens: main window resizes to 400, 200, but, when I drag open the window, I now see the response links (in a right  floading side div)  for the month *are* now appearing in the iFrame -- because I hard coded enough dimensional space for them to appear.   So, the CGI is working.

But, how to  instruct the iFrame to dynamically resize to accept the content coming from the cgi, while leaving the rect of the main window in which it is embeded, unchanged?

but this was a *very* useful exercise... I never knew about iFrames... very powerful tool.. as a temp work around I set fixed dimension for the iFrame,  and in order not to have a blank area, set src to the cgi, which responds differently if the request is a GET which it is on page load... and it puts in the current month by parsing today's date: html and cgi code below... but the above question remains.

###### HTML #####

<li> Archives: <br />
## iFrame with hard coded dimenion to hold content from cgi stdout
## height ="1" and width="1" will not work

<iframe name="archiveIndex" border="0" width="130" height ="140" src="/cgi-bin/buildTakaIndex.cgi"></iframe></li></ul>
## user can navigate the past with:
<form method="post" action="/cgi-bin/buildTakaIndex.cgi" target="archiveIndex">
<select name="month"> ## option list here for 12 months.##</select><br>
<select name="year">##option list for years in the archive## </select>
<input type=submit value="Go"></form>

###### CGI  #####
### uses the Revolution transcript interpreter ###

#!revolution
on startup
global tYear, tMonth

if $REQUEST_METHOD is "POST" then

## user has made selections from the option pull downs and submitted      
## trap the data

put "" into PostIn
      repeat until length(PostIn) >= $CONTENT_LENGTH
            read from stdin until ""
                put it after PostIn
        end repeat        
      put  urlDecode (PostIn)  into tDataIn       
      
# create small array:

split tDataIn by "&" and "="

#extract elements

put tDataIn["year"] into tYear
put tDataIn["month"] into tMonth

else
## this is a GET request from the page on first load
## just  parse today's date:
## and insert the current month's links

put word 1 of item 2 of the long date into tMonth
put item 3 of the long date into tYear

#we have to wipe leading space
delete char 1 of tYear

end if

#  create a path now to the past
# and get directory list of days for the month

put "../taka/past/" & tYear& "/" &tMonth &"/" into tArchiveMonth
 set the defaultFolder to tArchiveMonth
 put the folders into tMonthList
 
 # We have our list of days now just have to
#  build html response
 
 ##put format ("<body onload=\"resizeTo(200,200)\"") into tIndex
 ## this "onload" directive re-sizes the main window
 ## meanwhile the iFrame remains at 1 pixel in width
## and output from this CGI is not visible
 ## so I took it out and put simply:
 
put "<body> into tIndex
 put "<h4>" & tMonth & ", " & tYear & "</h4>" after tIndex
 
## create the links chunk

repeat for each line x in tMonthList
  if x contains tMonth then #skips dot files
  put tagIt(x,tYear,tMonth) & "&nbsp;" after tIndex
  end if
end repeat
put "</body>" after tIndex

## We're done, just send it to stdout,  minimal http headers first:

put "Content-Type: text/html" & cr
put "Content-Length:" && the length of tIndex & cr & cr
put tIndex

end startUp

function tagIt tDay,tYear,tMonth
  set the itemdel to "_"
  put format (cr & "<a href=\"/taka/past/")& tYear & "/" &tMonth &"/" & tDay & format ("/\" & target=\"_blank\">") & item 2 of tDay & "</a>" into tDayLink
  return tDayLink
end tagit

Sivakatirswami

0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 500 total points
Comment Utility
It looks like the sizing has to be dynamic in the mainpage as the form is submittted; and we probably have to use the styles to do it.

We can use the onsubmit event of the form to trigger:
<form method="post" action="buildindex.cgi" target="archiveIndex"
onsubmit="setSize()">

A small script goes in the head of the main page

<script type="text/javascript">
function setSize()
{
document.getElementById('archiveIndex').style.width='140px';
document.getElementById('archiveIndex').style.height='120px';
}
</script>


And we us the sam value for both the id and the name of the iframe:

<iframe id="arhchiveIndex" name="archiveIndex"
    style="height:1px;width:1px" src=""></iframe>

Cd&
0
 

Author Comment

by:Sivakatirswami
Comment Utility
I'm sorry I didn't get back to you sooner... very busy here ... I finally opted for a fixed iFrame size set on the html page itself... While our solution was not that of the original question...,  it turned out to be much better web design anyway.. We are not popping open anything.. the iFrame is static, sized to fit in the side bar and comfortably hold the data we want to display...

You open a lot of new doors for me... thank you! ;-)

Sivakatirswami
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

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

16 Experts available now in Live!

Get 1:1 Help Now