网页加载前展示5秒广告 - 提升用户体验的简单方法
<html>
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
<title><?php echo $j12; ?></title>
<body style='margin:0;padding:0;height:100%' scroll=no>
<!-- 添加广告代码 -->
<div id='ad' style='position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: #ffffff;'>
<div style='text-align: center; padding-top: 50px;'>
<img src='广告图片链接' alt='广告图片' style='width: 80%; max-width: 600px;'>
</div>
<script>
// 5秒后隐藏广告
setTimeout(function(){
document.getElementById('ad').style.display = 'none';
}, 5000);
</script>
</div>
<iframe id='infrm' name='infrm' marginwidth='0' marginheight='0' width='100%' scrolling=auto src='http://cdn.qh.cn' frameborder='0' height='100%'allowfullscreen='true'></iframe>
<script>
$('#Zl').html('<iframe id='infrm' name='infrm' marginwidth='0' marginheight='0' width='100%' scrolling=auto src='http://cdn.qh.cn' frameborder='0' height='100%'allowfullscreen='true'></iframe>');
$(document).ready(function(){
function fix_height(){ $('#infrm').attr('height', (($(window).height())-5) + 'px');}
$(window).resize(function(){ fix_height(); }).resize();
$('#infrm').contentWindow.focus();
});
</script>
<script>
var iframe = document.getElementById('infrm');
if (iframe.attachEvent){ // 兼容IE写法
iframe.attachEvent('onload', function(){
// iframe加载完成后要进行的操作
})
} else {
iframe.onload = function(){
// iframe加载完成后要进行的操作
document.title='<?php echo $title ?>';
top.document.getElementById('paneloading').style.display = 'none';
top.document.getElementById('Zl').style.display = '';
// alert('加载完成');
}
}
</script>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/mzFR 著作权归作者所有。请勿转载和采集!