HTML5   发布时间:2022-04-25  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了html5手机浏览器之---------------小图拼大图(基本兼容所有浏览器)大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
1.前言。
  如题。
2.代码
   以下为主页html实现,@L_@R_675_11284@_1@图片的完整例子,请直接下载附件demo.rar
<html>
<head>
<title>小车测试</title>
<Meta http-equiv="content-type" content="text/html;charset=GBK">
<script
	src="http://qzonestyle.gtimg.cn/open/mobile/light_app/js/device.js"></script>
<style type="text/css">
#buttonLeft {
	BACkground: url(ptz_left.png) no-repeat;
	width: 100px;
	height: 100px;
	border: 0px;
}

#buttonRight {
	BACkground: url(ptz_right.png) no-repeat;
	width: 100px;
	height: 100px;
	border: 0px;
}

#buttonDown {
	BACkground: url(ptz_down.png) no-repeat;
	width: 100px;
	height: 100px;
	border: 0px;
}

#buttonUp {
	BACkground: url(ptz_up_highlight.png) no-repeat;
	width: 100px;
	height: 150px;
	border: 0px;
}

#buttonLeftUp {
	BACkground: url(ptz_left_up.png) no-repeat;
	width: 100px;
	height: 100px;
	border: 0px;
}

#buttonRightUp {
	BACkground: url(ptz_right_up.png) no-repeat;
	width: 100px;
	height: 100px;
	border: 0px;
}

#buttonDownLeft {
	BACkground: url(ptz_left_down.png) no-repeat;
	width: 100px;
	height: 100px;
	border: 0px;
}

#buttonDownRight {
	BACkground: url(ptz_right_down.png) no-repeat;
	width: 100px;
	height: 100px;
	border: 0px;
}

body {
	margin: 0px;
	padding: 0px;
	text-align: center;
}

div {
	margin: 0px;
	padding: 0px;
	margin: auto;
}

.cl {
	clear: both;
}

#div1 {
 	BACkground: #FEE9F4; 
	width: 440px;
}

#div2 {
	BACkground: #E9FEF0;
	width: 440px;
}

#div3 {
	BACkground: #C7C2Fc;
	width: 440px;
}
</style>


</head>

<script>
	function load() {
		//下面两种方法效果是一样的
		//document.getElementById("target").onclick();
		//document.getElementById("target").click();
	}
	function stop() {
		//alert("down");
		device.send({
			datapoint : [ {
				id : 500005,value : 4
			} ],vibrate : 1,// 1为发送时振动,可选
			nfc : 1,// 1为近场通信方式,可选
			lifetime : 20,// 生命期,范围1到604800秒,可选
			onsuccess : function(ret) { // 发送成功回调
				device.log('onsuccess: ' + JSON.Stringify(ret));
			},onAck : function(ret) { // 接收响应成功回调
				device.log('onAck: ' + JSON.Stringify(ret));
			},onError : function(ret) { // 发送失败回调
				device.log('onError: ' + JSON.Stringify(ret));
			}
		});

	}

	function up() {
		//alert("up");
		device.send({
			datapoint : [ {
				id : 500005,value : 0
			} ],onError : function(ret) { // 发送失败回调
				device.log('onError: ' + JSON.Stringify(ret));
			}
		});

	}
	function down() {
		//alert("down");
		device.send({
			datapoint : [ {
				id : 500005,value : 1
			} ],onError : function(ret) { // 发送失败回调
				device.log('onError: ' + JSON.Stringify(ret));
			}
		});

	}

	function left() {
		//alert("down");
		device.send({
			datapoint : [ {
				id : 500005,value : 2
			} ],onError : function(ret) { // 发送失败回调
				device.log('onError: ' + JSON.Stringify(ret));
			}
		});

	}

	function right() {
		//alert("down");
		device.send({
			datapoint : [ {
				id : 500005,value : 3
			} ],onError : function(ret) { // 发送失败回调
				device.log('onError: ' + JSON.Stringify(ret));
			}
		});

	}

	function changeButtonHilight(postion) {
		//上下左右,用0,1,2,3表示. postion=0,3 . state=0表示暗,1表示亮
		var ids = [ "buttonUp","buttonDown","buttonLeft","buttonRight" ];
		var pngHihgLight = [ "ptz_up.png","ptz_down.png","ptz_left.png","ptz_right.png" ];
		var pngLowLight = [ "ptz_up_highlight.png","ptz_down_highlight.png","ptz_left_highlight.png","ptz_right_highlight.png" ];

		var idPostion = parseInt(postion);
		var myid;
		myid = ids[idPostion];
		document.getElementById(myid).style.BACkground = "url("
				+ pngHihgLight[postion] + ") no-repeat";
		for (var i = 0; i < pngHihgLight.length; i++) {
			//自己变色
			if (i != postion) {
				document.getElementById(ids[i]).style.BACkground = "url("
						+ pngLowLight[i] + ") no-repeat";
			}
		}
	}
	function changeButtonLowlight(postion) {
		//上下左右,用0,"ptz_right_highlight.png" ];

		var idPostion = parseInt(postion);
		var myid;
		myid = ids[idPostion];
		document.getElementById(myid).style.BACkground = "url("
				+ pngLowLight[postion] + ") no-repeat";
	}
</script>

<body onload="load()"
	style="-webkit-user-SELEct: none; -webkit-touch-callout: none;
	ontouchstart="return false;text-align:center;align:center;" >
	<script type="text/javascript">
		
	</script>

	<!-- 	[align=center;padding-left: 30px]
		<div
			style="height: 88px; width: 88px; border: 0px solid #000; float: left" >
			<button id="buttonLeftUp"></button>
		[/align]

		<div
			style="height: 88px; width: 88px; border: 0px solid #000; float: left">
			<button id="buttonUp"
				style="-webkit-user-SELEct: none; -moz-user-SELEct: none;"
				onmousedown="changeButtonHilight(0);up();"
				ontouchstart="changeButtonHilight(0);return false;"
				ontouchend="changeButtonLowlight(0)"></button>
		</div>
		[align=center;padding-left: 30px]
		<div
			style="height: 88px; width: 88px; border: 0px solid #000; float: left">
			<button id="buttonLeft" onmousedown="changeButtonHilight(2);left();"
				style="float: left; -webkit-user-SELEct: none; -moz-user-SELEct: none;"
				ontouchstart="changeButtonHilight(2);return false;"
				ontouchend="changeButtonLowlight(2)"></button>
		[/align]
		<div
			style="height: 88px; width: 88px; border: 0px solid #000; float: left">

		</div>
		[align=center;padding-left:30px]
		<div
			style="height: 88px; width: 88px; border: 0px solid #000; float: left">
			<button id="buttonDownLeft"></button>
		[/align]
		<div
			style="height: 88px; width: 88px; border: 0px solid #000; float: left">
			<button id="buttonDown" onmousedown="changeButtonHilight(1);down()"
				style="-webkit-user-SELEct: none; -moz-user-SELEct: none;"
				ontouchstart="changeButtonHilight(1);return false;"
				ontouchend="changeButtonLowlight(1)"></button>
		</div>
		<div style="height: 88px; width: 88px; border: 0px solid #000; float: left">
			<button id="buttonDownRight"></button>
		</div>
		<!-- 		<div style="height: 88px; width: 88px; border: 0px solid #000; float: left"> -->

		<!-- 		</div> -->
		<!-- 		<div style="height: 88px; width: 88px; border: 0px solid #000;"> -->
		<!-- 			<button id="buttonDownLeft"></button> -->
		<!-- 		</div> -->

	</div>
	<!-- 		<div -->
	<!-- 			style="width: 455px; height: 300px; float: left; border: 1px solid #000; margin: 10px;">div2a</div> -->
	<!-- 		<div -->
	<!-- 			style="width: 455px; height: 300px; float: right; border: 1px solid #000; margin: 10px;">div2b</div> -->
	<!-- 		<div class="cl"></div> -->
	<!-- 	<div id="div3"> -->
	<!-- 		<div -->
	<!-- 			style="width: 300px; height: 300px; float: left; border: 1px solid #000; margin: 10px;">div3a</div> -->
	<!-- 		<div -->
	<!-- 			style="width: 300px; height: 300px; float: left; border: 1px solid #000; margin: 10px;">div3b</div> -->
	<!-- 		<div -->
	<!-- 			style="width: 300px; height: 300px; float: right; border: 1px solid #000; margin: 10px;">div3c</div> -->
	<!-- 		<div class="cl"></div> -->
	<!-- 	</div> -->



</body>
</html>

@H_@L_944_6@_11@  3.注意事项。   
        

大佬总结

以上是大佬教程为你收集整理的html5手机浏览器之---------------小图拼大图(基本兼容所有浏览器)全部内容,希望文章能够帮你解决html5手机浏览器之---------------小图拼大图(基本兼容所有浏览器)所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。