First, create a "pageshow" event for your page: (this should be a "pageshow" event, not a "pagebeforeshow", because in the second case you will not get the height - the page is hidden)
// bind "pageshow" event to your page $("#PageID").live("pageshow", function (event, data) { // do something... });
Inside this event, check the size of the header, footer and page (with paddings and margins): Something like:
var header_height = $("div[data-role=header]").height(); var footer_height = $("div[data-role=footer]").height(); var page_height = $("div[data-role=page]").height();
Then calculate and set the new canvas size:
$("#MyCanvas").css({"height":page_height - (header_height + footer_height )});
All sample code:
// bind "pageshow" event to your page $("#PageID").live("pageshow", function (event, data) { var header_height = $("div[data-role=header]").height(); var footer_height = $("div[data-role=footer]").height(); var page_height = $("div[data-role=page]").height(); $("#MyCanvas").css({"height":page_height - (header_height + footer_height )}); });
source share