Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

Passing screen resolution to CGI using javascript and form

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
neilmcaliece
Asked:
neilmcaliece
  • 4
  • 2
1 Solution
 
CJ_SCommented:
function document_onload()
{
   document.forms[0].screenW.value=screen.availWidth;
   document.forms[0].screenH.value=screen.availheight;
}
window.onload=document_onload;

regards,
CJ
0
 
bebonhamCommented:
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
 
neilmcalieceAuthor Commented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
CJ_SCommented:
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
 
CJ_SCommented:
one typo:
availheight
should be
availHeight
0
 
neilmcalieceAuthor Commented:
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
 
CJ_SCommented:
IE is also case sensitive (should be at least)...:-)

Glad to be of service!

regards,
CJ
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now