Solved

Passing screen resolution to CGI using javascript and form

Posted on 2001-08-03
7
213 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
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
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…

803 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