<script language="JavaScript"> //对联广告代码
var delta = 0.8; //0.015
var collection;
var closeB = false;
function floaters() {
this.items = [];
this.addItem = function(id, x, y, content) {
document.write('<DIV id=' + id + ' style="Z-INDEX: 10; POSITION: absolute; width:80px; height:60px;left:' + (typeof (x) == 'string' ? eval(x) : x) + ';top:' + (typeof (y) == 'string' ? eval(y) : y) + '">' + content + '</DIV>');
var newItem = {};
newItem.object = document.getElementById(id);
newItem.x = x;
newItem.y = y;
this.items[this.items.length] = newItem;
}
this.play = function() {
collection = this.items;
setInterval('play()', 30);
}
}
function play() {
if (screen.width <= 800 || closeB) {
for (var i = 0; i < collection.length; i++) {
collection[i].object.style.display = 'none';
}
return;
}
for (var i = 0; i < collection.length; i++) {
var followObj = collection[i].object;
var followObj_x = (typeof (collection[i].x) == 'string' ? eval(collection[i].x) : collection[i].x);
var followObj_y = (typeof (collection[i].y) == 'string' ? eval(collection[i].y) : collection[i].y); if (followObj.offsetLeft != (document.body.scrollLeft + followObj_x)) {
var dx = (document.body.scrollLeft + followObj_x - followObj.offsetLeft) * delta;
dx = (dx > 0 ? 1 : -1) * Math.ceil(Math.abs(dx));
followObj.style.left = followObj.offsetLeft + dx;
} if (followObj.offsetTop != (document.body.scrollTop + followObj_y)) {
var dy = (document.body.scrollTop + followObj_y - followObj.offsetTop) * delta;
dy = (dy > 0 ? 1 : -1) * Math.ceil(Math.abs(dy));
followObj.style.top = followObj.offsetTop + dy;
}
followObj.style.display = '';
}
}
function closeBanner() {
closeB = true;
return;
}
var theFloaters = new floaters();
theFloaters.addItem('followDiv1', 6, 100, '<span align="right" class="close" onclick="closeBanner()"><strong>×</strong></span><a href="http://www.google.com.cn" target="_blank"><img src="/Images/index_bk1.gif" width=100 height=300 border=0></a>');
theFloaters.addItem('followDiv2', window.screen.width - 100 - 6, 100, '<span align="right" class="close" onclick="closeBanner()"><strong>×</strong></span><a href="http://www.baidu.com" target="_blank"><img src="/Images/index_bk1.gif" width=100 height=300 border=0></a>');
theFloaters.play();
</script>以上代码引入.aspx文件中,IE浏览器下可正常显示,火狐等其他浏览器都不能正常显示,求高手指点!!asp.net 对联广告浏览器显示
var delta = 0.8; //0.015
var collection;
var closeB = false;
function floaters() {
this.items = [];
this.addItem = function(id, x, y, content) {
document.write('<DIV id=' + id + ' style="Z-INDEX: 10; POSITION: absolute; width:80px; height:60px;left:' + (typeof (x) == 'string' ? eval(x) : x) + ';top:' + (typeof (y) == 'string' ? eval(y) : y) + '">' + content + '</DIV>');
var newItem = {};
newItem.object = document.getElementById(id);
newItem.x = x;
newItem.y = y;
this.items[this.items.length] = newItem;
}
this.play = function() {
collection = this.items;
setInterval('play()', 30);
}
}
function play() {
if (screen.width <= 800 || closeB) {
for (var i = 0; i < collection.length; i++) {
collection[i].object.style.display = 'none';
}
return;
}
for (var i = 0; i < collection.length; i++) {
var followObj = collection[i].object;
var followObj_x = (typeof (collection[i].x) == 'string' ? eval(collection[i].x) : collection[i].x);
var followObj_y = (typeof (collection[i].y) == 'string' ? eval(collection[i].y) : collection[i].y); if (followObj.offsetLeft != (document.body.scrollLeft + followObj_x)) {
var dx = (document.body.scrollLeft + followObj_x - followObj.offsetLeft) * delta;
dx = (dx > 0 ? 1 : -1) * Math.ceil(Math.abs(dx));
followObj.style.left = followObj.offsetLeft + dx;
} if (followObj.offsetTop != (document.body.scrollTop + followObj_y)) {
var dy = (document.body.scrollTop + followObj_y - followObj.offsetTop) * delta;
dy = (dy > 0 ? 1 : -1) * Math.ceil(Math.abs(dy));
followObj.style.top = followObj.offsetTop + dy;
}
followObj.style.display = '';
}
}
function closeBanner() {
closeB = true;
return;
}
var theFloaters = new floaters();
theFloaters.addItem('followDiv1', 6, 100, '<span align="right" class="close" onclick="closeBanner()"><strong>×</strong></span><a href="http://www.google.com.cn" target="_blank"><img src="/Images/index_bk1.gif" width=100 height=300 border=0></a>');
theFloaters.addItem('followDiv2', window.screen.width - 100 - 6, 100, '<span align="right" class="close" onclick="closeBanner()"><strong>×</strong></span><a href="http://www.baidu.com" target="_blank"><img src="/Images/index_bk1.gif" width=100 height=300 border=0></a>');
theFloaters.play();
</script>以上代码引入.aspx文件中,IE浏览器下可正常显示,火狐等其他浏览器都不能正常显示,求高手指点!!asp.net 对联广告浏览器显示
jQuery(document).ready(function(){
var suspendcode="<DIV id=lovexin1 style='Z-INDEX: 10; LEFT: 6px; POSITION: absolute; TOP: 105px; width: 100; height: 300px;background-color:#FFFFFF;'><img src='/sysImages/ad/close.gif' onClick='javascript:adhide()' width='100' height='14' border='0' vspace='3' alt='关闭对联广告'><br/><a href='http://www.lzisti.net.cn/ztzl/gxcgz/' target='_blank'><img src='/sysImages/ad/1.jpg' width='100' height='300' border='0'></a></DIV>"
jQuery("body").append(suspendcode);
suspendcode="<DIV id=lovexin2 style='Z-INDEX: 10; right: 6px; POSITION: absolute; TOP: 105px; width: 100; height: 300px;background-color:#FFFFFF;'><img src='/sysImages/ad/close.gif' onClick='javascript:adhide()' width='100' height='14' border='0' vspace='3' alt='关闭对联广告'><br/><a href='http://www.lzisti.net.cn/ztzl/gxcgz/' target='_blank'><img src='/sysImages/ad/2.jpg' width='100' height='300' border='0'></a></DIV>"
jQuery("body").append(suspendcode);
//flash格式调用方法
//<EMBED src='flash.swf' quality=high WIDTH=100 HEIGHT=300 TYPE='application/x-shockwave-flash' id=ad wmode=opaque></EMBED>
adinterval=setInterval("heartBeat()",1);
});
var lastScrollY=0;
function heartBeat(){
var diffY=jQuery(document).scrollTop();
var percent=.3*(diffY-lastScrollY);
if(percent>0){
percent=Math.ceil(percent);
}
else{
percent=Math.floor(percent);
}
//alert(jQuery("#lovexin1").css("top"));
jQuery("#lovexin1").css("top",parseInt(jQuery("#lovexin1").css("top")) + percent);
jQuery("#lovexin2").css("top",parseInt(jQuery("#lovexin2").css("top")) + percent);
lastScrollY=lastScrollY+percent;
}
function adhide(){
jQuery("#lovexin1").hide();
jQuery("#lovexin2").hide();
clearInterval(adinterval);
}