I was curious if anyone had a code snippet to prevent landscape view
from happening in an application? I currently haven't optimized my CSS
to propagate if the phone gets tilted 90 degrees and would like to
prevent landscape view from creeping up.
Also, one other question, is it possible to force only a numerical
keyboard to come up for certain input boxes?
Thanks for the help. :-)
- sf
<body onorientationchange=”orientationChanged()”>
Then in orientationChanged() look at the window.orientation property
to determine the orientation of the screen. You can then set CSS
properties accordingly.
As far as input boxes, if you use a form element name that uses 'zip'
in it, a numerical input box will be used. For example:
<input type="text" name="thisisnotazip" size="20" />
Good luck!
August
Numerical kybd = how the field is named.
-=Randy
On Nov 6, 2007, at 8:39 AM, "Steve Finkelstein" <s...@stevefink.net>
wrote:
I'm having a bit of difficulty panning the view back into portrait ..
if any suggestions to the following code can be made it would be
totally wonderful... I figured it would do the trick, but apparently
not. :-)
function orientationChanged() {
if ( window.orientation == '90' || window.orientation == '-90' ||
window.orientation == '180' )
/* flip back to portrait view. */
window.orientation = 0;
alert(window.orientation);
}
- sf
What I was suggesting is something more like:
function orientationChanged() {
if ( window.orientation == '90' || window.orientation == '-90' ||
window.orientation == '180' )
document.body.className = 'landscape';
else
document.body.className = 'portrait';
}
Then, in your CSS, you can have different styles for elements in
portrait or landscape mode.
Depending on what, exactly, you're trying to do, though, Randy is
right: it's simpler just to use percents, i.e. 100%, etc. as width
parameters. This allows your page to display regardless of orientation.
Also keep in mind that it's quite possible (I'd say likely) that Apple
will release an "iPhone HD" with, say, a 240 pixels per inch display,
or the again-rumored table with who-knows- how-many-pixels. Anything
based on 320 pixels wide will need reworked. By using %s, you can keep
yourself from having several versions of the same site.
August
And yeah, I just found out myself that window.orientation is a
read-only property. Try to cancel the Event during the capturing phase
isn't workable either.
Time to write additional CSS!
a special background image on the html tag would not queue anything
nsubs...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/iphonewebdev?hl=en
-~----------~----~----~----~------~----~------~--~---
<script type="application/x-javascript">
addEventListener("load", function()
{
setTimeout(hideURLbar, 0);
}, false);
function hideURLbar()
{
window.scrollTo(0, 1);
}
</script>
isn't needed because the other script does it all.