Solved

Passing screen resolution to CGI using javascript and form

Posted on 2001-08-03
7
216 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…
Suggested Courses

617 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