• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

How to create an advertising image flying in the web page?

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have saw from some web site( ex. www.china.com) small advertising images that can move around in the web page. These small images can just fly like a butterfly within the web page, and when you click on it, the advertised links will be opened. Does anybody know how to do this in DHTML and JavaScript? If possible, I would appreciate some sample code as well. Thanks in advance.
 
Ranch Hand
Posts: 937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
liang,
this is the javascript they used for that( rt click and click view source)

<!--
document.ns = navigator.appName == "Netscape"
//--
var rnumx1=new Array();
var rnumx2;
var rnumx3;
rnumxtemp="";
for(i=0;i<3;i++){
rnumx2 =Math.round(Math.random()*10);
rnumx2!=10 ? rnumx3=rnumx2:rnumx3=9;
//document.write("["+rnumx3+"]");
rnumx1[i]=rnumx3;
if (rnumx1[0]>4||rnumx1[0]<1){
rnumx1[0]=1;
}
if (rnumx1[1]>2&&rnumx1[0]==4){
rnumx1[1]=1;
}
rnumxtemp+=new String(rnumx1[i]);
}
//--
window.screen.width>800 ? imgheight=150:imgheight=rnumxtemp
window.screen.width>800 ? imgright=20:imgright=20
window.screen.width>800 ? imgleft=20:imgleft=20
function threenineload()
{
if (navigator.appName == "Netscape")
{
if(document.getElementById) {
document.getElementById('threenine').pageY=pageYOffset+window.innerHeight-imgheight;
document.getElementById('threenine').pageX=imgright;
document.getElementById('threenine1').pageY=pageYOffset+window.innerHeight-imgheight;
document.getElementById('threenine1').pageX=imgleft;
} else {
document.threenine.pageY=pageYOffset+window.innerHeight-imgheight;
document.threenine.pageX=imgright;
document.threenine1.pageY=pageYOffset+window.innerHeight-imgheight;
document.threenine1.pageX=imgleft;
}
threeninemove();
}
else
{
threenine.style.top=document.body.scrollTop+document.body.offsetHeight-imgheight;
threenine.style.right=imgright;
threenine1.style.top=document.body.scrollTop+document.body.offsetHeight-imgheight;
threenine1.style.left=imgleft;
threeninemove();
}
}
function threeninemove()
{
if(document.ns)
{
if(document.getElementById) {
document.getElementById('threenine').style.top=pageYOffset+window.innerHeight-imgheight
document.getElementById('threenine').style.right=imgright;
document.getElementById('threenine1').style.top=pageYOffset+window.innerHeight-imgheight
document.getElementById('threenine1').style.left=imgleft;
} else {
document.threenine.top=pageYOffset+window.innerHeight-imgheight
document.threenine.right=imgright;
document.threenine1.top=pageYOffset+window.innerHeight-imgheight
document.threenine1.left=imgleft;
}
setTimeout("threeninemove();",40)
}
else
{
threenine.style.top=document.body.scrollTop+document.body.offsetHeight-imgheight;
threenine.style.right=imgright;
threenine1.style.top=document.body.scrollTop+document.body.offsetHeight-imgheight;
threenine1.style.left=imgleft;
setTimeout("threeninemove();",80)
}
}
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true)
{
document.write("<div id=threenine1 style='position: absolute;width:64;top:200;visibility: visible;z-index: 1'><a href=http://ads.china.com/globeedu.html target=_blank><img src=http://ads.china.com/globeedu_icon.gif border=0 width=80 height=80></a></div>");
document.write("<div id=threenine style='position: absolute;width:64;top:200;visibility: visible;z-index: 1'><object classid='clsid 27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='80' height='80'><param name=movie value='http://ads.china.com/mercan/80_80.swf'><param name=quality value=high><embed src='http://ads.china.com/mercan/80_80.swf' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='80' height='80'></embed></object></div>");
threenineload()
}
//-->
</script>
<!-- gif floating end -->
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at http://www.dynamicdrive.com they have all scripts that deal with this matter. It is a rather easy thing to do in HTML and I have a couple of these scripts hiding on my harddrive somewhere.
Eric
 
catch it before it slithers away! Oh wait, it's a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic