I’ve an html page with varying size. Based on the conditions i hide some contents.
How can i get the width and height of the body with javascript, so that i can resize the window size dynamically based on the amount of contents of the page.
Thanks…
I’ve an html page with varying size. Based on the conditions i hide some
Share
I’d be careful resizing browser windows because it can very quickly get annoying (particularly if the user opens the page directly and not as a pop-up). What if a user wants a bit of space around the content to make it easier to read? In most browsers you can also turn off certain Javascript effects like moving and resizing windows – they may even be off by default.
icabod’s idea of wrapping the content in a div should work fine at least for the height. If the width still shows the entire width of the current window then try adding
float:leftand it will fit to the width of the content.A nice solution would be to use a lightbox script to display the content. I don’t know of any off-hand that would resize to HTML/iframed content, but it’s worth looking into.