首页 > Web开发 > 详细

JS简单实用的浮动窗口

时间:2015-09-01 02:15:02      阅读:290      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
*{ margin:0; padding:0;}
a img{ border:0;}	
</style>
</head>
<body>


<div style="height:2000px; background:#ccc; display:none;">

</div>

<!--div id="floatAd" style=" position:fixed !important; position:absolute; _top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight)); z-index: 2147483647; left: 50%; margin-left: -240px !important; top: 50%; margin-top: -210px !important; background:url(images/onlineSay.jpg) no-repeat; width:487px; height:350px; cursor:pointer;">
<div onclick="closeFAd();" style=" width:26px; height:26px; float:right;"></div>
<div style="width:487px; height:320px; float:right;" onclick="open_online();"></div>
</div>
<div id="floatSide" style=" width:141px; height:579px; position:fixed !important; position:absolute; _top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight)); z-index: 99999; right:0; top:6%; background:url(images/onlineTel.gif);cursor:pointer;" onclick="open_online();></div-->


</body>
</html>
<script type="text/javascript" src="online.js"></script>

?

?

// JavaScript Document


//浮动广告图片
var floatAdImg = "http://www.onestopweb.cn/online/onlineSay.jpg";
//浮动侧栏图片
var floatSideImg = "http://www.onestopweb.cn/online/onlineTel.gif";

//打开在线沟通
function open_online()
{
	window.open(‘http://p.qiao.baidu.com//im/index?siteid=7342332&ucid=7601325‘);
}

//浮动广告
document.writeln("<div id=\"floatAd\" style=\" position:fixed !important; position:absolute; _top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight)); z-index: 2147483647; left: 50%; margin-left: -240px !important; top: 50%; margin-top: -210px !important; background:url("+floatAdImg+") no-repeat; width:487px; height:350px; cursor:pointer; display:none; \">");
document.writeln("<div onclick=\"closeFAd();\" style=\" width:26px; height:26px; float:right;\"></div>");
document.writeln("<div style=\"width:487px; height:320px; float:right;\" onclick=\"open_online();\"></div>");
document.writeln("</div>");

//浮动侧栏
document.writeln("<div style=\" width:141px; height:579px; position:fixed !important; position:absolute; _top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight)); z-index: 99999; right:0; top:6%; background:url("+floatSideImg+");cursor:pointer;\" onclick=\"open_online();\"></div>");

//关闭浮动广告
function closeFAd()
{
	document.getElementById(‘floatAd‘).style.display = ‘none‘;
}

//打开浮动广告
function showFAd()
{
	document.getElementById(‘floatAd‘).style.display = ‘block‘;
}

//打开浮动窗口
function showFloat()
{
	document.getElementById(‘floatAd‘).style.display = ‘block‘;
}

//打开窗口 20 秒仅执行一次
setTimeout(showFAd,20000);

//每个 30 秒执行一次
setInterval(showFloat,30000);

?

效果图:
bubuko.com,布布扣
?

?

JS简单实用的浮动窗口

原文:http://onestopweb.iteye.com/blog/2239739

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!