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.
DougP
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