Html试玩发布模板

<!DOCTYPE html>
<html>
	<head>
		<meta charset='utf-8' />
		<title>$game_name$</title>
		<meta name='viewport' content='width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no'
		/>
		<meta name="renderer" content="webkit"/>
		<meta name='apple-mobile-web-app-capable' content='yes' />
		<meta name='full-screen' content='true' />
		<meta name='x5-fullscreen' content='true' />
		<meta name='360-fullscreen' content='true' />
		<!--meta name="laya" screenorientation ="landscape"/-->
		<meta name="laya" screenorientation="portrait" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
		<meta http-equiv='expires' content='0' />
		<meta http-equiv="Cache-Control" content="no-siteapp"/>
		
	</head>
	<body style="background-color:#ffffff;">
		<div id="normal" style="display:none;width:0px;height:0px;margin:auto;position:relative;top:0px;left:0px;">
						
		</div>
	</body>
</html>

<script>
function init(){ 
	//2019 此处需要设置
	window.unity="true";console.log("window.unity 已经设置");
	//2019-05-15 andy 修复edge浏览器模式下,竖屏有滚动条问题,画布大小Laya设置有问题
	document.body.style.overflow="hidden";
	if(typeof mraid=="undefined"){
		console.error("不支持mraid");
		showMyAd(1);
	}else{console.log("支持mraid",window.mraid);
		window.mraid=mraid;
		mraid.addEventListener("stateChange", mraidStateChange);
		console.log("mraid.getState",mraid.getState());
		if (mraid.getState() == 'loading'){       
			mraid.addEventListener("ready", mraidReady); 
		}else{    
			showMyAd(1);     
		}
	}
}
//监听mraid StateChange事件
function mraidStateChange(state){
	if( state== 'loading'){
		console.log("loading");
	}else if( state== 'default'){
		console.log("mraid default");
		mraid.getMaxSize();
		//toggleLayer('expanded', 'normal');
	}else if( state== 'expanded'){
		console.log("mraid expanded");
		//toggleLayer('normal', 'expanded');
	}else if( state== 'resized'){
		console.log("mraid resized");
		
	}else if( state== 'hidden'){
		console.log("mraid hidden");
		
	}else{
		
	}
}
//监听mraid ready事件
function mraidReady(){
	mraid.removeEventListener("ready", mraidReady); 
	if(mraid.isViewable()){
		showMyAd(2);
	}else{
		mraid.addEventListener('viewableChange',function(viewable) {
			if (viewable) {
				mraid.removeEventListener('viewableChange', arguments.callee);
				showMyAd(3);
			}
		})
	}
}

//打开连接
function openSite(url){
    mraid.open(url);
}
//SMS
function sendSMS(number){
	if (!mraid.supports("sms")){
		alert("MRAID says SMS is not supported on this device.");
	}else{
	   mraid.open("sms://" + number);
	}
}
//打开电话
function callNumber(number){
	if (!mraid.supports("tel")){
		alert("MRAID says calling is not supported on this device.");
	}else{
		mraid.open("tel://" + number);
	}
}
//播放视频
function playVideo(url){
    mraid.playVideo(url);
}
//储存图片
function storePicture(url){
    if (!mraid.supports("storePicture")){
		alert("MRAID says storePicture is not supported on this device.");
	}else{
		mraid.storePicture(url);
	}
}
function expand(){       
    mraid.setOrientationProperties({"allowOrientationChange":false, "forceOrientation":"portrait"});
    mraid.expand();
}
//广告关闭
function collapse(){
	mraid.close();
}
function createCalendarEvent(){
	if (!mraid.supports("calendar")){
		alert("MRAID says calendar is not supported on this device.");
	}else{
		var calendarObject = {description:"Mayan Apocalypse/End of World", location:"everywhere", start:"2013-12-21T00:00-05:00", end:"2013-12-22T00:00-05:00"};
		mraid.createCalendarEvent(calendarObject);
	}
}

//设置层级显示
function toggleLayer(fromLayer, toLayer){
	var fromElem = document.getElementById(fromLayer);
	fromElem.style.display = 'none';
	var toElem = document.getElementById(toLayer);
	toElem.style.display = '';
}
//设置meta[name=viewport]
function setupViewport(width){
	var element = document.querySelector("meta[name=viewport]");
	if (!element){
		element = document.createElement("meta");
		element.name = "viewport";
		element.content = "width=" + width + ", user-scalable=no";
		document.getElementsByTagName('head')[0].appendChild(element);
	}else{
		element.content = "width=" + width + ", user-scalable=no";
	}
}




//显示广告
function showMyAd(where){console.log("where",where);
    var loading = document.getElementById("apus_loading");
	if(loading){
		loading.style.display = ''; 
	}
    
	//此处复制code.js代码即可
	$code.js$
	

}

init();

</script>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值