alex242 Posted September 4, 2010 Share Posted September 4, 2010 Is there a function that returns the height/width of the area where websites are rendered within a browser? Link to comment Share on other sites More sharing options...
Ingolme Posted September 4, 2010 Share Posted September 4, 2010 The innerHeight and innerWidth properties of the window object do that:http://w3schools.com/jsref/prop_win_innerheight.aspThis is Javascript, though. Link to comment Share on other sites More sharing options...
alex242 Posted September 4, 2010 Author Share Posted September 4, 2010 Yea, I saw that, but it says it's only supported by FireFox; but after you brought it up, I tested it (with the code bellow) and it seemed to work on both FireFox and Chrome, but not EE. Is there a workaround or am I doing something wrong? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head><script type="text/javascript">var hi = window.innerHeightdocument.write( hi );</script></head><body></body></html> Link to comment Share on other sites More sharing options...
Ingolme Posted September 4, 2010 Share Posted September 4, 2010 It does actually work in more browser, according to this:http://www.quirksmode.org/dom/w3c_cssom.htmlUnfortunately, I can't think of any good Internet Explorer alternatives.You might be able to get the width by getting the document.body.offsetWidth, and if you give the <html> and <body> elements 100% height in CSS, then document.body.offsetHeight might be able to tell you the height of the window space.I don't think screen.width and screen.height are what you want. Link to comment Share on other sites More sharing options...
alex242 Posted September 4, 2010 Author Share Posted September 4, 2010 Is this what you meant? It doesn't appear to be working... could you take a look at it? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head><style type="text/css">html, body { height:100% }</style><script type="text/javascript">var hi = window.innerHeight;var bye = document.body.offsetHeight;document.write( hi );document.write( bye );</script></head><body></body></html> Oh, and I did think of a good alternative, just it's not an easy one to implement: STOP USING INTERNET EXPLORER ALREADY! GOD ITS THE TWENTY FIRST CENTURY!!!!! STUPID PEOPLE!!! STUPID MICROSOFT!!! *wehw* sorry, been holding that up for a while. Link to comment Share on other sites More sharing options...
Ingolme Posted September 4, 2010 Share Posted September 4, 2010 What does document.body.offsetHeight show?If that doesn't work, try document.documentElement.offsetHeight Link to comment Share on other sites More sharing options...
alex242 Posted September 4, 2010 Author Share Posted September 4, 2010 Ha! It works! Take that evil internet Explorer demons! err... uh... sorry, and Thank You. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.