How to get/find height and width of window using javascript

By knowing heigth and width of window we can place divs, messages,status wherever we want by using top left property of element. for that you should provide value of top and left to view in different monitors to get dynamic top left position you must find out the window width & height. following code will demostrate you to find out the window width & height which supports in  almost all browsers .


 
function windimension(){
if(window.innerHeight !==undefined)
{
var width= window.innerWidth;
var height=window.innerHeight]; // most browsers
}
else{ // IE varieties
var D= (document.body.clientWidth)? document.body: document.documentElement;
var width= D.clientWidth;
var height=D.clientHeight;
}

}



Hope this will help u.......

Comments

Popular posts from this blog

Use Chroma DB vector database in RAG application using llama index & Deepseek R1 local model

I have created an application to extract text from image using AI

Download DeepSeek R1 Model Locally free | AI RAG with LlamaIndex, Local Embedding and Ollama

Understanding the Singleton Design Pattern in C#

Create Chat bot application using Python, Streamlit and Gemini AI