This is a discussion on How to detect UserInner browser? within the HTML, CSS and Javascript Coding Techniques forums, part of the Web Development category; Hi, I have tried to detect a users inner browser window size but can't find one. What I need ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi, I have tried to detect a users inner browser window size but can't find one. What I need is to obtain the available space within a browser excluding tollbars etc, just where the website is shown, and deliver content appropriately. Any help would be very much appreciated.
__________________ S.VinothkumaR Behind me is infinite power, Before me is Endless Possibility, Around me is Boundless Opportunity, Why should I fear! |
| Sponsored Links |
| |||
| Hi Vinoth Try the below code var scrW = 0, scrH = 0, scrOfX = 0, scrOfY = 0; if( typeof( window.innerWidth ) == 'number' ) { scrW = window.innerWidth; scrH = window.innerHeight; } else { if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { scrW = document.documentElement.clientWidth; scrH = document.documentElement.clientHeight; } else { if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { scrW = document.body.clientWidth; scrH = document.body.clientHeight; } } } if( typeof( window.pageYOffset ) == 'number' ) { scrOfY = pageYOffset; scrOfX = pageXOffset; } else { if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft; } else { if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft; } } } |
| |||
| thnx Mr.Senthil! I will try that out.
__________________ S.VinothkumaR Behind me is infinite power, Before me is Endless Possibility, Around me is Boundless Opportunity, Why should I fear! |
| |||
| Use as follows buddy, Code: <style type="text/css">
html, body { overflow: auto; }
</style>
<script type="text/javascript">
function getWinSize() {
var winWidth = 0, winHeight = 0, d = document;
if (typeof (window.innerHeight) == 'number') {
winWidth = window.innerWidth;
winHeight = window.innerHeight;
} else {
if (d.documentElement && d.documentElement.clientHeight) {
winWidth = d.documentElement.clientWidth;
winHeight = d.documentElement.clientHeight;
} else {
if (d.body && d.body.clientHeight) {
winWidth = d.body.clientWidth;
winHeight = d.body.clientHeight;
}
}
}
document.getElementById('win').innerHTML = winWidth + ' x ' + winHeight;
}
window.onresize = getWinSize;
</script>
<div id="win"></div> |
| |||
| function pageWidth() { return window.innerWidth != null? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null; } function pageHeight() { return window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.bod y != null? document.body.clientHeight:null; } |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to detect a CD Drive in C#? | oxygen | C# Programming | 1 | 10-27-2007 05:00 AM |
| How would you detect and minimize memory leaks in Java? | oxygen | Java Programming | 1 | 07-26-2007 05:01 AM |
| How would you detect and minimize memory leaks in Java? | H2o | Java Programming | 1 | 07-24-2007 03:45 AM |
| How to detect collisions between 3D objects in Java ME (J2ME) M3G ? | itbarota | J2ME | 1 | 07-19-2007 01:03 AM |
| How to detect collisions between 3D objects in Java ME (J2ME) M3G ? | itbarota | J2ME | 0 | 07-17-2007 11:53 PM |