* Login   * Register


Last visit was:
It is currently Sun Feb 25, 2018 10:38 am
View unanswered posts
View active topics





Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Quảng cáo chạy dọc 2 bên
PostPosted: Sun May 31, 2009 1:35 pm 
Offline

Joined: Thu Feb 05, 2009 11:43 am
Posts: 11
---------
Mời bạn tham khảo bài viết hướng dẫn làm Quảng cáo chạy dọc 2 bên. Quảng cáo chỉ xuất hiện khi màn hình có độ phân giải chiều ngang lớn hơn 980 pixels. Ở đây code được viết cho 800x600

Phần hiển thị trong trang

<!--Phần cho bên trái-->
<DIV id=divAdLeft style='LEFT: 1px; WIDTH: 110px; POSITION: absolute; TOP: 71px'>
<a href="http://hoahoctro.com" target="_blank">
<IMG hspace=0 src='link đến ảnh' width=110 border=0>
</a>
</DIV>
<!--Phần cho bên phải-->
<DIV id=divAdRight style='LEFT: 892px; WIDTH: 110px; POSITION: absolute; TOP: 71px'>
<a href="http://hoahoctro.com" target="_blank">
<IMG hspace=0 src='link đến ảnh' width=110 border=0>
</a>
</DIV>
<div align="center">
</div>

Nội dung File JavaScript

<script language="javascript">
var adRWidth=110;
var adLWidth=1002;
function FloatTopDiv(){
startX = document.body.clientWidth - adRWidth, startY = -110;
var ns = (navigator.appName.indexOf('Netscape') != -1);
var d = document;
if (document.body.clientWidth < 980) startX = - adRWidth;
function ml(id)
{
var el=d.getElementById?d.getElementById(id):d.all?d.a ll[id]:d.layers[id];
if(d.layers)el.style=el;
el.sP=function(x,y)
{
this.style.left=x;this.style.top=y;
};
el.x = startX;
el.y = startY;
return el;
}
window.stayTopLeft=function()
{
if (document.body.clientWidth < 980)
{
ftlObj.x = - adRWidth;ftlObj.y = 0; ftlObj.sP(ftlObj.x, ftlObj.y);
}
else
{
if (document.documentElement && document.documentElement.scrollTop)
var pY = ns ? pageYOffset : document.documentElement.scrollTop;
else if (document.body)
var pY = ns ? pageYOffset : document.body.scrollTop;
if (document.body.scrollTop > 10){ startY = 3 } else { startY = 10 };
if (document.body.clientWidth >= 1024)
{
ftlObj.x = document.body.clientWidth - adRWidth;
ftlObj.y += (pY + startY - ftlObj.y)/8;
ftlObj.sP(ftlObj.x, ftlObj.y);
}
else
{
ftlObj.x = startX;
ftlObj.y += (pY + startY - ftlObj.y)/8;
ftlObj.sP(ftlObj.x, ftlObj.y);
}
}
setTimeout('stayTopLeft()', 1);
}
ftlObj = ml('divAdRight');
stayTopLeft();
}
function FloatTopDiv2()
{
startX2 = document.body.clientWidth - adLWidth, startY2 = -100;
var ns2 = (navigator.appName.indexOf('Netscape') != -1);
var d2 = document;
if (document.body.clientWidth < 980) startX2 = -adRWidth;
function ml2(id)
{
var el2=d2.getElementById?d2.getElementById(id):d2.all ?d2.all[id]:d2.layers[id];
if(d2.layers)el2.style=el2;
el2.sP=function(x,y)
{
this.style.left=x;this.style.top=y;
};
el2.x = startX2;
el2.y = startY2;
return el2;
}
window.stayTopLeft2=function()
{
if (document.body.clientWidth < 980)
{
ftlObj2.x = - adRWidth;ftlObj2.y = 0; ftlObj2.sP(ftlObj2.x, ftlObj2.y);
}
else
{
if (document.documentElement && document.documentElement.scrollTop)
var pY2 = ns2 ? pageYOffset : document.documentElement.scrollTop;
else if (document.body)
var pY2 = ns2 ? pageYOffset : document.body.scrollTop;

if (document.body.scrollTop > 10) { startY2 = 3 } else { startY2 = 10 };

if (document.body.clientWidth >= 1024)
{
ftlObj2.x = 0;
ftlObj2.y += (pY2 + startY2 - ftlObj2.y)/8;
ftlObj2.sP(ftlObj2.x, ftlObj2.y);
}
else
{
ftlObj2.x = startX2;
ftlObj2.y += (pY2 + startY2 - ftlObj2.y)/8;
ftlObj2.sP(ftlObj2.x, ftlObj2.y);
}
}
setTimeout('stayTopLeft2()', 1);
}
ftlObj2 = ml2('divAdLeft');
stayTopLeft2();
}
function ShowAdDiv()
{
var objAdDivLeft = document.getElementById('divAdLeft');
var objAdDivRight = document.getElementById('divAdRight');
if (document.body.clientWidth < 980)
{
objAdDivLeft.style.left = - adRWidth;
objAdDivRight.style.left = - adRWidth;
}
else
{
objAdDivLeft.style.left = 0;
objAdDivRight.style.left = document.body.clientWidth - adRWidth;
FloatTopDiv();
FloatTopDiv2();
}
}
ShowAdDiv();
</script>


- Bạn có thể cho nội dung vào cùng 1 chỗ, hoặc tách riêng ra rồi link đến file JavaScript


You do not have the required permissions to view the files attached to this post.


Report this post
Top
 Profile E-mail  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 


Who is online

Users browsing this forum: No registered users and 0 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron

Free Forum · php-BB© · Internationalization Project · Report abuse · Terms Of Use/Privacy Policy
© Forums-Free.com 2009