PDA

View Full Version : Banner thay đổi tự động??



tinhyeulangle
06-07-2009, 13:26
Chào các bạn!

Mình muốn làm banner quảng cáo cho trang web giống các banner quảng cáo như vnexpress hay 1 số báo đang sử dụng:

Banner chia sẻ: sau khi chạy hết banner này thì chạy banner kế tiếp...lặp liên tục.

Dữ liệu sẽ load từ database lên,bạn nào đã làm hoặc biết cách xin chỉ giúp mình.

Mình viết C#,sql2005.

Trân trọng!

Q.Anh
06-07-2009, 14:49
bạn có thể dung newid() trong sql và dung thread để load dư liệu là được
nếu ai có cách khác hiệu quả thì chỉ bảo cho mình nhé Email: DoYouWantTohelpme@yahoo.com
còn đây là đĩa chỉ để biết cách dùng newId() http://msdn.microsoft.com/en-us/library/ms190348.aspx

tinhyeulangle
06-07-2009, 19:21
bạn có thể dung newid() trong sql và dung thread để load dư liệu là được



Cách của bạn ở trên là random mất rồi,refresh web lại thì mới chạy banner mới.

Bạn thấy các bạnner trên vnexpress,cứ chạy hết banner này là chạy ra banner khác.

Q.Anh
07-07-2009, 09:42
Cách của bạn ở trên là random mất rồi,refresh web lại thì mới chạy banner mới.

Bạn thấy các bạnner trên vnexpress,cứ chạy hết banner này là chạy ra banner khác.

chỗ banner của ban là 1 file include thi bạn chỉ cần dùng thread trong C#để cho sleep 1 khoang thời gian là được thôi mà minh đã từng làm như thế rồi nhưng đây là đối phó thôi không tối ưu đâu nếu ai có cách khách hay hơn thì bảo mình nhé

vokhanhthuy
07-07-2009, 23:33
<html>
<head>
<style type="text/css">
#baner
{
position:relative;
top:0px;
overflow:hidden;
width:500px;
height:70px;
clip:rect(0px, 500px, 0px, 70px);
background-color:#FFF;
}
#baner1
{
position:relative;
top:5px;
left:0px;
width:480px;
height:60px;
}
#baner2
{
position:relative;
top:-55px;
left:500px;
width:480px;
height:60px;
}
</style>
<script type="text/javascript">
function loadDefault()
{
var baner1 = document.getElementById("baner1");
var baner2 = document.getElementById("baner2");
baner1.style.left=0;
baner2.style.left = 500;
wait = false;
}
function moveImage()
{
if(wait==false)
{
baner1.style.left = parseInt(baner1.style.left)-25;
baner2.style.left = parseInt(baner2.style.left)-25;
if(parseInt(baner1.style.left)==-500)
{
baner1.style.left=500;
wait=true;
}
if(parseInt(baner2.style.left)==-500)
{
baner2.style.left=500;
wait=true;
}
setTimeout("moveImage()",50);
}
else
{
setTimeout("moveImage()",2000);
wait=false;
}
}
</script>
</head>
<body onLoad="loadDefault();moveImage()">
<div align="center">
<div id="baner">
<img src="baner1.jpg" name="baner1" id="baner1" >
<img src="baner2.jpg" name="baner2" id="baner2" >
</div>
</div>
</body>
</html>