Solved

Passing screen resolution to CGI using javascript and form

Posted on 2001-08-03
7
211 Views
Last Modified: 2006-11-17
Hi,

I have  CGI program that sends a webpage back to a users browser.

The html which calls the form is omething like this :


<FORM action="http://www.domain.com/cgi.exe" method="post">
<INPUT name="username" type="hidden" value="username">
<INPUT name="password" type="hidden" value="password">
<INPUT maxLength=15 name="roomname" size=15>
<input name="screenW" type="hidden">
<input name="screenH" type="hidden">
<INPUT name="submit" type="submit" value=" Enter Room ">

</form>


I would like to be able to pass the screen height and width information to the cgi.exe CGI program so I need some kind of javascript program which will fill out the values of two variables (screenH and screenW) in the form when the page is loaded so when the user clicks the form the correct information will be sent to tge resulting CGI program.

This must work in both Netscape and IE

Points set high to get a quick answer.

Thanks

Neil McAliece
0
Comment
Question by:neilmcaliece
  • 4
  • 2
7 Comments
 
LVL 22

Accepted Solution

by:
CJ_S earned 300 total points
ID: 6348595
function document_onload()
{
   document.forms[0].screenW.value=screen.availWidth;
   document.forms[0].screenH.value=screen.availheight;
}
window.onload=document_onload;

regards,
CJ
0
 
LVL 8

Expert Comment

by:bebonham
ID: 6348615
if you are looking for the size of the browser window, and not the screen resolution, then there is

for both ns4 and ns6
window.innerWidth
window.innerHeight


and for ie it is
document.body.clientWidth
document.body.clientHeight


otherwise, CJ_S is right on!

0
 

Author Comment

by:neilmcaliece
ID: 6348648
Hi CJ_S - this is what I'm looking for - however - how do I make this code execute when the page is loaded - I have no experience with javascript - only server side CGI progrmming so don't know how to make it execute.

Thanks

Neil
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 22

Expert Comment

by:CJ_S
ID: 6348668
If you copy it right away as I wrote down, it will execute right away. the

window.onload

event will call the document_onload function when the document has finished loading. if you also need to submit the form right away, just add the following as the last line in the function:
document.forms[0].submit();

regards,
CJ
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6348679
one typo:
availheight
should be
availHeight
0
 

Author Comment

by:neilmcaliece
ID: 6348705
Ok - got it. My next question was going to be why doesn't the height make it through to the CGI program in Netscape but it was because of the typo in the availHeight variable. I guess IE is not case sensitive.

Thanks - this is most helpful.

Neil
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6348728
IE is also case sensitive (should be at least)...:-)

Glad to be of service!

regards,
CJ
0

Featured Post

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

Join & Write a Comment

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

759 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

20 Experts available now in Live!

Get 1:1 Help Now