How to Display Java Script variable in HTML Page?

chaitanya Thota

New member
Hi friend
I go a requirement that i have to get the screen width from java script page(using window.innerWidth) and store the width in a variable and display the value in HTML File.

Ex: Java Script Code

x=window.innerWidth.

This gets the width and store the value in x. Now i have to display this x value in a HTML or FTL page but not alert message, just display. Is there any way to do this???

If not possible tell me other ways what u know but the screen resolution must be stored in a variable and pass that to HTML or FTL.


Thanks
Chaitanya
 
Make a div tag and set the id to resolution. Then use innerHTML to set the text within the div like so;

in HTML:
<div id="resolution"> </div>

in javascript:
x = window.innerWidth;
document.getElementByID("resolution").innerHTML = x;

That's it!
 
Back
Top