Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

moving background as table background

Status
Not open for further replies.

dongbamage

Programmer
Nov 3, 2004
32
GB
Hi there I have a moving javascript background, that I would like to be a background for just a table, rather than my entire background.

I can choose to give it absolute co-ordinates, but this then messes up with different resoutions, also if I do it like this my other javascripts do not display even if left uncovered by the background.

A quick pointer or 2 on how to put this on a specific layer rather than on the entire document would be great!

Heres the unmodified background code:

PHP:
<BODY BGCOLOR="#000000" onLoad="fly()">

<SCRIPT LANGUAGE="JavaScript">

// Star Travel - Moving Background with 3D Effect
// This script and many more from :
// [URL unfurl="true"]www.rainbow.arch.scriptmania.com[/URL]

<!-- Begin
SmallStars = 30; 
LargeStars = 10;
SmallYpos = new Array();
SmallXpos = new Array();
LargeYpos = new Array();
LargeXpos = new Array();
Smallspeed= new Array();
Largespeed= new Array();
ns=(document.layers)?1:0;
if (ns) {
for (i = 0; i < SmallStars; i++) {
document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0 BGCOLOR='#FFFFF0' CLIP='0,0,1,1'></LAYER>");
}
for (i = 0; i < LargeStars; i++) {
document.write("<LAYER NAME='ln"+i+"' LEFT=0 TOP=0 BGCOLOR='#FFFFFF' CLIP='0,0,2,2'></LAYER>");
   }
}
else {
document.write('<div style="position:absolute;top:120px;left:225px">');
document.write('<div style="position:relative">');
for (i = 0; i < SmallStars; i++) {
document.write('<div id="si" style="position:absolute;top:120;left:225;width:1px;height:1px;background:#fffff0;font-size:1px"></div>');
}
document.write('</div>');
document.write('</div>');
document.write('<div style="position:absolute;top:120px;left:225px">');
document.write('<div style="position:relative">');
for (i = 0; i < LargeStars; i++) {
document.write('<div id="li" style="position:absolute;top:120;left:225;width:2px;height:2px;background:#ffffff;font-size:2px"></div>');
}
document.write('</div>');
document.write('</div>');
}
WinHeight = 325;
WinWidth = 625;
for (i = 0; i < SmallStars; i++) {
SmallYpos[i] = Math.round(Math.random() * WinHeight);
SmallXpos[i] = Math.round(Math.random() * WinWidth);
Smallspeed[i]= Math.random() * 5 + 1;
}
for (i = 0; i < LargeStars; i++) {
LargeYpos[i] = Math.round(Math.random() * WinHeight);
LargeXpos[i] = Math.round(Math.random() * WinWidth);
Largespeed[i] = Math.random() * 10 + 5;
}
function fly() {
var WinHeight = 395;
var WinWidth = 625;
var hscrll = (document.layers)?window.pageYOffset:document.body.scrollTop;
var wscrll = (document.layers)?window.pageXOffset:document.body.scrollLeft;
for (i = 0; i < LargeStars; i++) {
LargeXpos[i] -= Largespeed[i];
if (LargeXpos[i] < -10) {
LargeXpos[i] = WinWidth;
LargeYpos[i] = Math.round(Math.random() * WinHeight);
Largespeed[i] = Math.random() * 10 + 5;
}
if (ns) {
document.layers['ln'+i].left = LargeXpos[i];
document.layers['ln'+i].top = LargeYpos[i] + hscrll;
}
else {
li[i].style.pixelLeft = LargeXpos[i];
li[i].style.pixelTop = LargeYpos[i] + hscrll;
   }
}
for (i = 0; i < SmallStars; i++) {
SmallXpos[i] -= Smallspeed[i];
if (SmallXpos[i] < -10) {
SmallXpos[i] = WinWidth;
SmallYpos[i] = Math.round(Math.random()*WinHeight);
Smallspeed[i] = Math.random() * 5 + 1;
}
if (ns) {
document.layers['sn'+i].left = SmallXpos[i];
document.layers['sn'+i].top = SmallYpos[i]+hscrll;
}
else {
si[i].style.pixelLeft = SmallXpos[i];
si[i].style.pixelTop = SmallYpos[i]+hscrll;
   } 
}
setTimeout('fly()', 10);
}
//  End -->
</SCRIPT>
</body>

Please help guys I'm stumped and stupid, but with a little help I think i can get this done!
 
i am afraid u may have to use IFRAMES(divs being absolute)...

Known is handfull, Unknown is worldfull
 
hmmm yeah :(

The website i a want to use it with is frameless, it uses php includes...

 
>>frameless

IFRAMES is inline frames (its like a page within a page)...

Known is handfull, Unknown is worldfull
 
That looks good thanks vbkris!

The background now fills the iframe, which can be positioned relatively! Great!

Now I just need to work out how to get the iframe below my table contents, rather than pushing them down the page...

Thanks m8!
 
Sweet! I have sorted out my layering using z-index and it seems to be working, all except my js ticker which won't display unless I alt-tab in and out of the browser window which makes it display one chunk at a time (ie my message says nothing, i then alt-tab in and out, it the 1st few words are statically displayed rather than moving, then I alt tab again, and more of my message is revealed, but still static...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top