File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes How to create an advertising image flying in the web page? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "How to create an advertising image flying in the web page?" Watch "How to create an advertising image flying in the web page?" New topic
Author

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

liang gu
Ranch Hand

Joined: Nov 05, 2001
Posts: 89
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.
sunitha reghu
Ranch Hand

Joined: Dec 12, 2002
Posts: 937
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 -->
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15003
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
 
 
subject: How to create an advertising image flying in the web page?
 
Threads others viewed
Icons creation
Inserting images on JSP page
Image files behind WEB-INF are not accessible
Recognizing Blank Images
Resizing the image and displaying it
IntelliJ Java IDE