Hi,
Thanks msevrens!
I think your solution should also consider:
- calling changepush() function outside of resizing, too > otherwise content may be non-100% on first page load
- setting minHeight instead of height > avoid scrollbars inside content
- adding orientationchange to resize function
- adjusting for first header and last footer on page (there may be multiple header/footers)
The following looks ok for me on ipad, FF, IE8, Op, Saf, Chrome (I haven't checked other devices). Script needs some fine-tuning, though.
- function stretchScreen ()
- {
- var dheight = $('html').height();
- var wheight = $(window).height();
- //height first header, content, last footer
- var overTop = $('div[data-role="page"]:first-child div[data-role="header"]:first-child').height();
- var cbody = $('div[data-role="page"]:first-child div[data-role="content"]:first-child').height();
- var overBottom = $('div[data-role="page"]:first-child div[data-role="footer"]:last-child').height();
- //correction
- var correct = overTop + overBottom;
- if (cbody < dheight || cbody < wheight)
- {
- changePush ();
- }
- if (wheight > dheight)
- {
- $('.b_menuContent').height(cheight);
- }
- //add orientationchange
- $(window).bind('resize orientationchange', function()
- {
- wheight = $(window).height();
- noscroll();
- changepush();
- });
- function noscroll()
- {
if (wheight > dheight) - {
- $('html').addClass('noscroll');
- } else if (wheight <= dheight)
- {
- $('html').removeClass('noscroll');
- } else {}
- }
- function changepush()
- {
- if (wheight > dheight)
- {
- $('div[data-role="content"]:first-child').css({'min-height' : wheight-correct+'px'});
- $.mobile.silentScroll(0);
- } else {
- $('div[data-role="content"]:first-child').css({'min-height' : dheight-correct+'px'});
- $.mobile.silentScroll(0);
- }
- }
- }
I'm also thinking about a solution similar to the link below, so besides theming the background there is also an option for a fullscreen background picture.
jquery plugin - full size image background
But I guess this is another story.
Regards,
Frequent