Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie Java help showing browser or screen dimenisions

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
0
36
US
I pieced together this code but it only displays My Browser is .
How can I make it display the variables Width and Height?
I also copied the window.onload = jsUpdateSize; in the <body> , thinking it needed to run that to get results.

Code:
<html>
<head>
<title>WhatsMyBrowser</title>
<script>
function jsUpdateSize(){
    // Get the dimensions of the viewport
    var width = window.innerWidth ||
                document.documentElement.clientWidth ||
                document.body.clientWidth;
    var height = window.innerHeight ||
                 document.documentElement.clientHeight ||
                 document.body.clientHeight;
    document.getElementById('jsWidth').innerHTML = width;  // Display the width
    document.getElementById('jsHeight').innerHTML = height;// Display the height
};
window.onload = jsUpdateSize;       // When the page first loads
window.onresize = jsUpdateSize;     // When the browser changes size
</script>
</head>
<body>
<script>
	document.write("<p>My Browser is</p>")
	window.onload = jsUpdateSize;       // When the page first loads
    window.onresize = jsUpdateSize;     // When the browser changes size
	document.write(document.getElementById('jsWidth').innerHTML = width)
	document.write(document.getElementById('jsHeight').innerHTML = height)
</script>
</body>
</html>

DougP
 
Sorry "no clue" newbie here.
So what is this forum for?
I have a Windows 8 phone can I make a hello world app for it using java?
we can start another post if so?

DougP
 
Hi

No idea about what a Windows phone supports, but some things are sure : 1) Java != JavaScript; 2) your original post has nothing to do with Java; 3) this forum has nothing to do directly with JavaScript.


Feherke.
[link feherke.github.com/][/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top