网站定位

时间:2017-05-14 14:05:32

标签: javascript android html ios

我有一个网站,大部分时间都会在手机上打开,我需要默认以横向模式显示该网站。 (虽然用户处于纵向模式,但它也应处于横向模式)。 请帮帮我,使用哪些代码...

我使用了这段代码,但它没有以任何方式帮助我......

<script>
  var start = function() {
    screen.orientation.lock('landscape-primary').then(
      startInternal,
      function() {
        alert('To start, rotate your screen to landscape.');

        var orientationChangeHandler = function() {
          if (!screen.orientation.type.startsWith('landscape')) {
            return;
          }
          screen.orientation.removeEventListener('change', orientationChangeHandler);
          startInternal();
        }

        screen.orientation.addEventListener('change', orientationChangeHandler);
      });
  }
  window.onload = start;
</script>

1 个答案:

答案 0 :(得分:0)

如果使用css,

可能会更容易;

    <?xml version="1.0" encoding="UTF-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.sample" android:versionCode="1" android:versionName="1.0">
    <supports-screens android:xlargeScreens="true"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.UPDATE_DEVICE_STATS"></uses-permission>

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="21"/>
    <application android:label="Sample" android:name="android.support.multidex.MultiDexApplication" android:icon="@mipmap/ic_launcher">
     <activity android:name="javafxports.android.FXActivity" android:label="Sample" android:configChanges="orientation|screenSize">
     <meta-data android:name="main.class" android:value="com.sample.Main"/>
     <meta-data android:name="debug.port" android:value="0"/>
     <intent-filter>
     <action android:name="android.intent.action.MAIN"/>
     <category android:name="android.intent.category.LAUNCHER"/>
     </intent-filter>
     </activity>
     <activity android:name="com.gluonhq.impl.charm.down.plugins.android.NotificationActivity"
        android:parentActivityName="javafxports.android.FXActivity">
     <meta-data android:name="android.support.PARENT_ACTIVITY" 
               android:value="javafxports.android.FXActivity"/>
      </activity>
      <activity
        android:name="com.sample.NotificationsController" >
    </activity>

html eg。;

case "date":
    if(a.value != null || a.value.length != 0) {
        var e = a.column.format,
        f = Fancy.Date.parse(a.value, e.read, e.mode);
        d.set(f);
    }
break;

case "date":
    if (e.format && e.format.read) {
        if(e.editor.getDate().length != 0) {
            var j = e.editor.getDate();
            a = Fancy.Date.format(j, e.format.read, void 0, e.format.mode)
        }
    }

case "date":
    return function(b) {
        if (null === b || 0 === b.length) return "";
            var c = Fancy.Date.parse(b, a.read, a.mode);
            return b = Fancy.Date.format(c, a.write, void 0, a.mode)
        }