- Joined
- Feb 22, 2006
- Messages
- 1,520
- Reaction score
- 0
Here's the script:
Now here's the story behind it... lol
I was perfectly content with it until my friend told me that the div was way off the screen and had to scroll to see it. So I added in some if statements to check screen resolutions. As soon as I do that the script stops working entirely...
Anyone see any problems with it?
Works fine and dandy with no if statements or anymore variables:
Any ideas to what's up?
Preview of working code: http://wh005h.com/ro/index.php
**Edit**
As a side note if anyone knows how to make the server time on it show a static time zone that would be awesome too ^_^
Good ahead and post it here rather than starting a new topic =p
time.getSeconds() and the others are clientside (flash runs clientside) but I need for it to display a static hour not varying by browser. Doesn't really matter what hour just for it show 1 timezone lol
Code:
function JSFX_FloatTopLeft()
{
var startX1 = 1250, startY1 = 100;
var startX2 = 1200, startY2 = 100;
var startX3 = 1000, startY3 = 100;
var startX4 = 950, startY4 = 100;
var startX5 = 900, startY5 = 100;
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
var px = document.layers ? "" : "px";
function ml(id)
{
var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
if(d.layers)el.style=el;
el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};
if(screen.height == 1600 && screen.width == 1200)
{
el.x = startX1; el.y = startY1;
}
else if(screen.height == 1400 && screen.width == 1050)
{
el.x = startX2; el.y = startY2;
}
else if(screen.height == 1280 && screen.width == 1024)
{
el.x = startX3; el.y = startY3;
}
else if(screen.height == 1152 && screen.width == 864)
{
el.x = startX4; el.y = startY4;
}
else(screen.height == 1024 && screen.width == 768)
{
el.x = startX5; el.y = startY5;
}
return el;
}
window.stayTopLeft=function()
{
var pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
ftlObj.y += (pY + startY - ftlObj.y)/8;
ftlObj.sP(ftlObj.x, ftlObj.y);
setTimeout("stayTopLeft()", 40);
}
ftlObj = ml("divStayTopLeft");
stayTopLeft();
}
JSFX_FloatTopLeft();
Now here's the story behind it... lol
I was perfectly content with it until my friend told me that the div was way off the screen and had to scroll to see it. So I added in some if statements to check screen resolutions. As soon as I do that the script stops working entirely...
Anyone see any problems with it?
Works fine and dandy with no if statements or anymore variables:
Code:
function JSFX_FloatTopLeft()
{
var startX = 1250, startY = 100;
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
var px = document.layers ? "" : "px";
function ml(id)
{
var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
if(d.layers)el.style=el;
el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};
el.x = startX; el.y = startY;
return el;
}
window.stayTopLeft=function()
{
var pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
ftlObj.y += (pY + startY - ftlObj.y)/8;
ftlObj.sP(ftlObj.x, ftlObj.y);
setTimeout("stayTopLeft()", 40);
}
ftlObj = ml("divStayTopLeft");
stayTopLeft();
}
JSFX_FloatTopLeft();
Any ideas to what's up?
Preview of working code: http://wh005h.com/ro/index.php
**Edit**
As a side note if anyone knows how to make the server time on it show a static time zone that would be awesome too ^_^
Good ahead and post it here rather than starting a new topic =p
time.getSeconds() and the others are clientside (flash runs clientside) but I need for it to display a static hour not varying by browser. Doesn't really matter what hour just for it show 1 timezone lol
Code:
time=new Date(); // time object
var seconds = time.getSeconds()
var minutes = time.getMinutes()
var hours = time.getHours()
if (hours<12) {
ampm = "AM";
}
else{
ampm = "PM";
}
while(hours >12){
hours = hours - 12;
}
if(hours<10)
{
hours = "0" + hours;
}
if(minutes<10)
{
minutes = "0" + minutes;
}
if(seconds<10)
{
seconds = "0" + seconds;
}
if(hours == 00)
{
hours = 12
}
clock_txt.text = hours + ":" + minutes + ":" + seconds +" "+ ampm;