html5 webapp广告,mui webAPP中投放广告方法

只需要把下面这一段放到你的页面即可

如下是百度联盟广告

mui.plusReady(function() {

if (plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {

mui.toast("当前网络不给力,无法加载广告",',',');

} else {

//屏幕真实宽度

var width = window.innerWidth;

var height = window.innerHeight;

//根据投放广告的比例,计算广告高度

var adHeight = parseInt(width) * 3 / 20;

//广告投放域名地址

var ltu = encodeURIComponent('http://www.apizl.com',',',');

//投放广告的服务端页面标题

var title = encodeURIComponent('爱资料',',',');

var url = 'http://pos.baidu.com/acom?adn=1&at=97&aurl=&cad=1&ccd=24&cec=UTF-8&cfv=18&ch=0&col=en-US&conOP=0&cpa=1&dai=1&dis=0&ltr=&lunum=6&n=99099160_cpr&pis=10000x10000&ps=0x0&qn=31f2f2a7de233256&rad=&rsi5=4&rss0=&rss1=&rss2=&rss3=&rss4=&rss5=&rss6=&rss7=&scale=20.3&skin=mobile_skin_white_blue&td_id=2206321&tn=template_inlay_all_mobile&tpr=1436841400149&ts=1&xuanting=0&tt=1436841400136.14.87.89&dtm=BAIDU_DUP2_SETJSONADSLOT&dc=2&wt=1&distp=1001';

url += '&conW=' + width + '&conH=' + adHeight + '&ltu=' + ltu;

url += '&di=u888888'; //广告id

url += '&pcs=' + width + 'x' + height;

url += '&psr=' + width + 'x' + height;

url += '&pss=' + width + 'x0';

url += '&rsi0=' + width + '&rsi1=' + adHeight;

url += '&ti=' + title;

var adBottom = mui.os.ios ? ('-' + adHeight + 'px') : '0';

var ad = plus.webview.create(url, 'ad', {

height: adHeight + 'px',

bottom: adBottom

},',',');

//目前Android平台不支持子webview的setStyle动画,因此分平台处理;

if (mui.os.ios) {

//为了支持iOS平台左侧边缘滑动关闭页面,需要append进去;

plus.webview.currentWebview().append(ad,',',');

ad.addEventListener('loaded', function() {

ad.setStyle({

bottom: '0',

transition: {

duration: 150

}

},',',');

},',',');

} else {

ad.addEventListener('loaded', function() {

ad.show('slide-in-bottom',',',');

},',',');

}

ad.appendJsFile('_www/js/ad.js',',',');

//设置主页面的底部留白,否则会被遮住;

document.querySelector('.mui-content').style.paddingBottom = adHeight + 'px';

}

},',',');

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值