You don't mean screen resolution. You are talking about browser window dimensions in pixels.
I'm not sure if you have the right and/or optimal trial objects and properties in the best order to determine x & y there. But assuming that you do, one major problem with IE in doing something like this is that it 'doesn't know' the window, document, nor page dimensions until the page has at least been parsed. It's complicated to get that in IE, so generally we wait until the window.onload event has fired before trying to figure this out (again assuming the code you have is right if used at the proper time):
Code:
<script type="text/javascript">
function dimfunc(){
var w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight|| e.clientHeight|| g.clientHeight;
/* do what you want with the x and y values here */
}
if (window.addEventListener){
window.addEventListener('load', dimfunc, false);
}
else if (window.attachEvent){
window.attachEvent('onload', dimfunc);
}
</script>
It's easier (jQuery determines what objects to query) and faster (jQuery determines when the DOM is loaded, which comes sooner than window.onload) using jQuery:
Code:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1./jquery.min.js"></script>
<script type="text/javascript">
jQuery(function($){
var x = $(window).width(), y = $(window).height();
/* do what you want with the x and y values here */
});
</script>
Bookmarks