I am trying to modify a script that I have that is used for popup ads and use it for a prompt for registering for my forum. The script is good for an advertisement that just sits there and doesnt move but I am looking for it to do a couple things.
1. I would like it to fly-in from the top-center and land at the bottom-left of the screen.
2. I would like it to appear 5 seconds after the page loads
3. I would like it to hover down as the user scrolls down the page
If anyone could help me out with this that would be great. I am a php/html/css guy and have not studied javascript yet. Here is the javascript code that I would like modifed:
PHP Code:
var tmr;
var t;
var obj;
function sFa() {
obj = gObj();
sLft();
shw(true);
t = 0;
sTmr();
}
function hFa() {
t = -100;
sTmr();
return false;
}
function sTmr() {
tmr = setInterval("fd()",20);
}
function fd() {
var amt = Math.abs(t+=10);
if(amt == 0 || amt == 100) clearInterval(tmr);
amt = (amt == 100)?99.999:amt;
function sLft() {
var w = 170; // set this to 1/2 the width of the faw div defined in the style sheet
// there's not a reliable way to retrieve an element's width via javascript!!
var l = (document.body.innerWidth)? document.body.innerWidth / 2:document.body.offsetWidth / 2;
obj.style.left = (l - w)+"px";
}
function gObj() {
return document.getElementById("faw");
}
function shw(b) {
(b)? obj.className = 'show':obj.className = '';
}
Thanks for the script but you did not include directions on where to put what. Remember, I am using this as a popup prompt to register to my site. I am including the Javascript in an external file and the css in its own file. Where and what do I have to include in the html file to make this start? Other files I have seen have included a line of javascript at the end, jsut before the closing body tag. I tested it out and my prompt just sits fixed in one position. Is it suppose to float or what is it suppose to do with this script?
Bookmarks