Solved

Passing screen resolution to CGI using javascript and form

Posted on 2001-08-03
7
212 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

895 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

15 Experts available now in Live!

Get 1:1 Help Now