wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Screen rotated between portrait and landscape on the fly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Screen rotated between portrait and landscape on the fly" Watch "Screen rotated between portrait and landscape on the fly" New topic
Author

Screen rotated between portrait and landscape on the fly

accnit Jai
Ranch Hand

Joined: Feb 15, 2011
Posts: 33
I have a requirement where I am using the portable device to display my webpage. my webpage is having 3 buttons; button1,button2 and button3 . button1 positioning at right corner of the screen and button2 at left corner of the screen. For button2, on page load i am taking the screen width and placing button2 at the middle of screen. the problem is, if i rotate the device to portrait to landscape then my button2 does not fit to the screen. can you please let me know how we can achieve this using by javascript ? so that button2 should set the position irrespective of screen resolution.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
http://davidbcalhoun.com/2010/using-mobile-specific-html-css-javascript

Eric
accnit Jai
Ranch Hand

Joined: Feb 15, 2011
Posts: 33
Thanks Eric,

This code achieve my requirement

// check the orientation, on every window.resize event occurs
window.onresize = checkOrientation;

function checkOrientation()
{
// Portrait mode
if(window.innerWidth < window.innerHeight){
alert('Portrait mode: ' + window.innerWidth + 'x' + window.innerHeight);
}
else{
alert('Landscape mode: ' + window.innerWidth + 'x' + window.innerHeight);
}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Screen rotated between portrait and landscape on the fly
 
Similar Threads
HoneyComb 3.0 Orientation Issues
Change the Printer Orientation??
How to force landscape under all circumstances?
How to get screen size at run time?
GUI - tile