我正在尝试弄清楚如何在用户将手机从竖屏模式切换到横屏模式时更改嵌入的网页 - 基本上是加载更适合更宽屏幕格式的视图。是否可以不从服务器调用新页面来完成此操作,即从CSS / JavaScript内部驱动它?
谢谢!
我正在尝试弄清楚如何在用户将手机从竖屏模式切换到横屏模式时更改嵌入的网页 - 基本上是加载更适合更宽屏幕格式的视图。是否可以不从服务器调用新页面来完成此操作,即从CSS / JavaScript内部驱动它?
谢谢!
您可以使用 window.orientation
属性。它的值是当前查看模式使用的角度。这里是一个简单的例子:
function updateOrientation()
{
var orientation=window.orientation;
switch(orientation)
{
case 0:
break;
case 90:
break;
case -90:
break;
}
}
您可以在此事件中使用此功能:
window.onorientationchange=updateOrientation;
希望有所帮助!
最好不要直接设定<条码>的变更>。 而是使用以下方法:
window.addEventListener( orientationchange , function (evt) {
switch(window.orientation) {
case 0: // portrait
case 180: // portrait
case 90: // landscape
case -90: // landscape
}
}, false);
我简直不敢相信没有人谈论CSS的规则。
@media screen and (max-width: 320px) // Portait Mode
{
/* CSS RULINGS */
p{}
body{}
}
@media screen and (min-width: 321px) // Landscape Mode
{
/* CSS RULINGS */
p{}
body{}
}
Safari 移动浏览器支持 orientationchange
事件以及窗口上的 orientation
属性,因此您可以执行以下操作:
window.onorientationchange = function() {
switch(window.orientation) {
case 0: // Portrait
case 180: // Upside-down Portrait
// Javascript to setup Portrait view
break;
case -90: // Landscape: turned 90 degrees counter-clockwise
case 90: // Landscape: turned 90 degrees clockwise
// Javascript to steup Landscape view
break;
}
}
我希望加入倒置模式,因为iPad的人机界面准则指出你应该支持所有屏幕方向,并且我希望iPad上的Safari(以及可能的未来iPhone版本)也支持此功能。
Safari移动版支持方向事件。
<body onorientationchange="updateOrientation();">
I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...
HI, In our application i am using corelocationframework when opening application a alert for allow and dont allow.when clicking on the allow for current location we will show current location.When ...
Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...
我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......
我希望我与四舍五入的累进角进行网上讨论。
我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。
We have a restaurant table that has lat-long data for each row. We need to write a query that performs a search to find all restaurants within the provided radius e.g. 1 mile, 5 miles etc. We have ...
I like to write bash shell scripts on my iPhone, put them in an app folder with an icon, plist, etc., so they execute like apps by tapping their icon on SpringBoard. This is not interactive like ...