Run JavaScript Code on Orientation Change


dojo.addOnLoad(function() 
{ 
	//run once on start up and then on each onorientationchange
	var orientation = window.orientation;
	
	/*
		orientation values:
		0 	portrait mode
    		90:  	landscape mode with the screen turned to the left
    		-90: 	landscape mode with the screen turned to the right
    	*/

	var height = window.innerHeight; 
	var div = dojo.byId('footerDiv'); 
	height -= 50; 
	div.style.marginTop = height.toString() + "px";

	window.onorientationchange = function() 
	{ 	
		console.log(" Height: " + window.innerHeight);


		var height = window.innerHeight; 
		var div = dojo.byId('footerDiv'); 
		height -= 50; 
		div.style.marginTop = height.toString() + "px"; 
	} 
});
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
No comments yetLogin first to comment...