html5 怎么打开一个app

html-css07

html5 怎么打开一个app,第1张

首先为了保证能够打开你的app,你必须要在androidManifest.xml中配置的filter中data的属性表述。

<data

android:pathprefix="/taoge/open" android:scheme="xttblog"></data>

androidManifest.xml

代码如下:

XML/HTML Code

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.taoge"

android:versionCode="2"

android:versionName="3.24.03" >

<uses-sdk

android:minSdkVersion="8"

android:targetSdkVersion="17" />

<application

android:allowBackup="true"

android:configChanges="orientation|screenSize"

android:icon="@drawable/logo"

android:label="@string/app_name"

android:logo="@drawable/logo"

android:sharedUserId="android.uid.system"

android:theme="@android:style/Theme.Light.NoTitleBar" >

<activity

android:name="xttblog.WelcomeActivity"

android:excludeFromRecents="true"

android:screenOrientation="portrait"

android:theme="@android:style/Theme.Light.NoTitleBar" >

<intent-filter>

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>

<intent-filter>

<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.BROWSABLE" />

<category android:name="android.intent.category.DEFAULT" />

<data android:pathPrefix="/taoge/open"

android:scheme="xttblog" />

</intent-filter>

</activity>

<activity

android:name="xttblog.AntRepairActivity"

android:label="@string/title_activity_ant_repair" >

</activity>

</application>

</manifest>

其次,你要在你的网页中访问xttblog://taoge/open。可以使用的元素有很多,如:script,iframe,img等。使用它们的src属性,访问xttblog://taoge/open。html5代码如下:

XML/HTML Code复制内容到剪贴板

<!DOCTYPE HTML>

<html>

<script>

function openapp(){

document.getElementById('xttblog').innerHTML='<iframe src="xttblog://taoge/open"></iframe>'

}

</script>

<body>

<div style="display:none" id="xttblog"></div>

<input type="button" value="打开app" onclick="openapp()">

</body>

</html>

不一样,需增加自适应标签来保持一样。

代码如下:

<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>

解释:Viewport指用户网页的可视区域,content中的“width”指的是虚拟窗口宽度,上面代码意为虚拟窗口/页面宽度初始比例为1,最小比例为1,最大比例为1,用户不可扩展,页面不可缩放。

扩展资料:

HTML5的事件属性和异常处理

事件属性

HTML 5 元素可拥有事件属性,这些属性在浏览器中触发行为,比如当用户单击一个HTML 5元素时启动一段 JavaScript。下面列出的事件属性,可以把它们插入 HTML 标签来定义事件行为。

HTML 5 中的新事件属性:

onabort, onbeforeunload, oncontextmenu, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, onerror, onmessage, onmousewheel, onresize, onscroll, onunload。

1.因为HTML5暂时无法短期内在PC普及,主要方向在使用高端浏览器的高端移动设备,所以可以用作开发Android系统的App。

2.但只有Android2.2以上、iOS3.2以上均支持HTML5,两大平台有望全系列支持HTML5。

3.HTML5可以用作离线应用的开发,离线应用就是把需要的资源先缓存到本地,下次再查看时无需联网。

4.使用HTML5离线应用带来的好处:提供更快、更简便的服务,代码可高度重用,服务发布方便。

5.HTML5主要应用:Web邮箱、WebRSS、Web地图等服务在无网络环境的使用。

6.HTML5技术重点关注在动画、游戏方面,地理定位方面的应用正在崛起,HTML5还被用于改善用户体验。