I need code for random pictures. Thanks

H

Hai Nguyen

Hi
I have the falling snow code, but instead of snow, I want to put my pictures
there. Therefore, the website will have random pictures falling (It's pretty
cool, I think). Can anyone help me?

The third line from the <!-- Begin is to put the falling snow dir


<script language=JavaScript1.2>

//START "FALLING STARS"

<!-- Begin

var no = 21;
var speed = 18;
var snowflake = "image/snow.gif";
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;

var dx, xp, yp;
var am, stx, sty;
var i, doc_width = 800, doc_height = 600;

if (ns4up) {

doc_width = self.innerWidth;

doc_height = self.innerHeight;

} else if (ie4up) {

doc_width = document.body.clientWidth;

doc_height = document.body.clientHeight;

}

dx = new Array();

xp = new Array();

yp = new Array();

am = new Array();

stx = new Array();

sty = new Array();

for (i = 0; i < no; ++ i) {

dx = 0;
xp = Math.random()*(doc_width-50);

yp = Math.random()*doc_height;

am = Math.random()*20;
stx = 0.02 + Math.random()/10;
sty = 0.7 + Math.random();
if (ns4up) {
if (i == 0) {

document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");

document.write("top=\"15\" visibility=\"show\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></layer>");

} else {

document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");

document.write("top=\"15\" visibility=\"show\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></layer>");

}

} else if (ie4up) {

if (i == 0) {

document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");

document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");

document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></div>");

} else {

document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");

document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");

document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></div>");

}

}

}

function snowNS() {
for (i = 0; i < no; ++ i) {
yp += sty;

if (yp > doc_height-50) {

xp = Math.random()*(doc_width-am-30);

yp = 0;

stx = 0.02 + Math.random()/10;

sty = 0.7 + Math.random();

doc_width = self.innerWidth;

doc_height = self.innerHeight;

}

dx += stx;

document.layers["dot"+i].top = yp;

document.layers["dot"+i].left = xp + am*Math.sin(dx);

}

setTimeout("snowNS()", speed);

}

function snowIE() {
for (i = 0; i < no; ++ i) {
yp += sty;

if (yp > doc_height-50) {

xp = Math.random()*(doc_width-am-30);

yp = 0;

stx = 0.02 + Math.random()/10;

sty = 0.7 + Math.random();

doc_width = document.body.clientWidth;

doc_height = document.body.clientHeight;

}

dx += stx;

document.all["dot"+i].style.pixelTop = yp;

document.all["dot"+i].style.pixelLeft = xp + am*Math.sin(dx);

}

setTimeout("snowIE()", speed);

}

if (ns4up) {

snowNS();

} else if (ie4up) {

snowIE();

}
// End -->
//END "FALLING STARS"
</SCRIPT>


THANK YOU VERY MUCH
 
D

David Berry

I'm not sure I understand. If you want to use your own image then just
change var snowflake = "image/snow.gif"; to the name of the image you want
to use.

--
David Berry - MCP
Microsoft MVP - FrontPage
FrontPage Support: http://www.msmvps.com/sitebuilder/
-----------------------------------
To assist you in getting the best answers for FrontPage support see:
http://msmvps.com/sitebuilder/articles/30119.aspx
-----------------------------------
Hai Nguyen said:
Hi
I have the falling snow code, but instead of snow, I want to put my
pictures there. Therefore, the website will have random pictures falling
(It's pretty cool, I think). Can anyone help me?

The third line from the <!-- Begin is to put the falling snow dir


<script language=JavaScript1.2>

//START "FALLING STARS"

<!-- Begin

var no = 21;
var speed = 18;
var snowflake = "image/snow.gif";
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;

var dx, xp, yp;
var am, stx, sty;
var i, doc_width = 800, doc_height = 600;

if (ns4up) {

doc_width = self.innerWidth;

doc_height = self.innerHeight;

} else if (ie4up) {

doc_width = document.body.clientWidth;

doc_height = document.body.clientHeight;

}

dx = new Array();

xp = new Array();

yp = new Array();

am = new Array();

stx = new Array();

sty = new Array();

for (i = 0; i < no; ++ i) {

dx = 0;
xp = Math.random()*(doc_width-50);

yp = Math.random()*doc_height;

am = Math.random()*20;
stx = 0.02 + Math.random()/10;
sty = 0.7 + Math.random();
if (ns4up) {
if (i == 0) {

document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");

document.write("top=\"15\" visibility=\"show\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></layer>");

} else {

document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");

document.write("top=\"15\" visibility=\"show\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></layer>");

}

} else if (ie4up) {

if (i == 0) {

document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");

document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");

document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></div>");

} else {

document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");

document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");

document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></div>");

}

}

}

function snowNS() {
for (i = 0; i < no; ++ i) {
yp += sty;

if (yp > doc_height-50) {

xp = Math.random()*(doc_width-am-30);

yp = 0;

stx = 0.02 + Math.random()/10;

sty = 0.7 + Math.random();

doc_width = self.innerWidth;

doc_height = self.innerHeight;

}

dx += stx;

document.layers["dot"+i].top = yp;

document.layers["dot"+i].left = xp + am*Math.sin(dx);

}

setTimeout("snowNS()", speed);

}

function snowIE() {
for (i = 0; i < no; ++ i) {
yp += sty;

if (yp > doc_height-50) {

xp = Math.random()*(doc_width-am-30);

yp = 0;

stx = 0.02 + Math.random()/10;

sty = 0.7 + Math.random();

doc_width = document.body.clientWidth;

doc_height = document.body.clientHeight;

}

dx += stx;

document.all["dot"+i].style.pixelTop = yp;

document.all["dot"+i].style.pixelLeft = xp + am*Math.sin(dx);

}

setTimeout("snowIE()", speed);

}

if (ns4up) {

snowNS();

} else if (ie4up) {

snowIE();

}
// End -->
//END "FALLING STARS"
</SCRIPT>


THANK YOU VERY MUCH
 
S

Steve Easton

Be advised that scripts such as this are very CPU intensive.
If you modify it to handle multiple images it can easily drive a 500 / 600 mhz CPU to 100% and cause
the machine / browser to freeze

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer

Hai Nguyen said:
Hi
I have the falling snow code, but instead of snow, I want to put my pictures
there. Therefore, the website will have random pictures falling (It's pretty
cool, I think). Can anyone help me?

The third line from the <!-- Begin is to put the falling snow dir


<script language=JavaScript1.2>

//START "FALLING STARS"

<!-- Begin

var no = 21;
var speed = 18;
var snowflake = "image/snow.gif";
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;

var dx, xp, yp;
var am, stx, sty;
var i, doc_width = 800, doc_height = 600;

if (ns4up) {

doc_width = self.innerWidth;

doc_height = self.innerHeight;

} else if (ie4up) {

doc_width = document.body.clientWidth;

doc_height = document.body.clientHeight;

}

dx = new Array();

xp = new Array();

yp = new Array();

am = new Array();

stx = new Array();

sty = new Array();

for (i = 0; i < no; ++ i) {

dx = 0;
xp = Math.random()*(doc_width-50);

yp = Math.random()*doc_height;

am = Math.random()*20;
stx = 0.02 + Math.random()/10;
sty = 0.7 + Math.random();
if (ns4up) {
if (i == 0) {

document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");

document.write("top=\"15\" visibility=\"show\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></layer>");

} else {

document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");

document.write("top=\"15\" visibility=\"show\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></layer>");

}

} else if (ie4up) {

if (i == 0) {

document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");

document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");

document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></div>");

} else {

document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");

document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");

document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></div>");

}

}

}

function snowNS() {
for (i = 0; i < no; ++ i) {
yp += sty;

if (yp > doc_height-50) {

xp = Math.random()*(doc_width-am-30);

yp = 0;

stx = 0.02 + Math.random()/10;

sty = 0.7 + Math.random();

doc_width = self.innerWidth;

doc_height = self.innerHeight;

}

dx += stx;

document.layers["dot"+i].top = yp;

document.layers["dot"+i].left = xp + am*Math.sin(dx);

}

setTimeout("snowNS()", speed);

}

function snowIE() {
for (i = 0; i < no; ++ i) {
yp += sty;

if (yp > doc_height-50) {

xp = Math.random()*(doc_width-am-30);

yp = 0;

stx = 0.02 + Math.random()/10;

sty = 0.7 + Math.random();

doc_width = document.body.clientWidth;

doc_height = document.body.clientHeight;

}

dx += stx;

document.all["dot"+i].style.pixelTop = yp;

document.all["dot"+i].style.pixelLeft = xp + am*Math.sin(dx);

}

setTimeout("snowIE()", speed);

}

if (ns4up) {

snowNS();

} else if (ie4up) {

snowIE();

}
// End -->
//END "FALLING STARS"
</SCRIPT>


THANK YOU VERY MUCH
 
M

MD Websunlimited

Just replace the name of the graphic image in the code.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 102 Components For FP
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Hai Nguyen said:
Hi
I have the falling snow code, but instead of snow, I want to put my pictures there. Therefore, the website will have random
pictures falling (It's pretty cool, I think). Can anyone help me?

The third line from the <!-- Begin is to put the falling snow dir


<script language=JavaScript1.2>

//START "FALLING STARS"

<!-- Begin

var no = 21;
var speed = 18;
var snowflake = "image/snow.gif";
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;

var dx, xp, yp;
var am, stx, sty;
var i, doc_width = 800, doc_height = 600;

if (ns4up) {

doc_width = self.innerWidth;

doc_height = self.innerHeight;

} else if (ie4up) {

doc_width = document.body.clientWidth;

doc_height = document.body.clientHeight;

}

dx = new Array();

xp = new Array();

yp = new Array();

am = new Array();

stx = new Array();

sty = new Array();

for (i = 0; i < no; ++ i) {

dx = 0;
xp = Math.random()*(doc_width-50);

yp = Math.random()*doc_height;

am = Math.random()*20;
stx = 0.02 + Math.random()/10;
sty = 0.7 + Math.random();
if (ns4up) {
if (i == 0) {

document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");

document.write("top=\"15\" visibility=\"show\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></layer>");

} else {

document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");

document.write("top=\"15\" visibility=\"show\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></layer>");

}

} else if (ie4up) {

if (i == 0) {

document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");

document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");

document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></div>");

} else {

document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");

document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");

document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></div>");

}

}

}

function snowNS() {
for (i = 0; i < no; ++ i) {
yp += sty;

if (yp > doc_height-50) {

xp = Math.random()*(doc_width-am-30);

yp = 0;

stx = 0.02 + Math.random()/10;

sty = 0.7 + Math.random();

doc_width = self.innerWidth;

doc_height = self.innerHeight;

}

dx += stx;

document.layers["dot"+i].top = yp;

document.layers["dot"+i].left = xp + am*Math.sin(dx);

}

setTimeout("snowNS()", speed);

}

function snowIE() {
for (i = 0; i < no; ++ i) {
yp += sty;

if (yp > doc_height-50) {

xp = Math.random()*(doc_width-am-30);

yp = 0;

stx = 0.02 + Math.random()/10;

sty = 0.7 + Math.random();

doc_width = document.body.clientWidth;

doc_height = document.body.clientHeight;

}

dx += stx;

document.all["dot"+i].style.pixelTop = yp;

document.all["dot"+i].style.pixelLeft = xp + am*Math.sin(dx);

}

setTimeout("snowIE()", speed);

}

if (ns4up) {

snowNS();

} else if (ie4up) {

snowIE();

}
// End -->
//END "FALLING STARS"
</SCRIPT>


THANK YOU VERY MUCH
 
M

MD Websunlimited

Really, this seems a little over stated. The problem would more than likely be the graphic processor and not the CPU.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 102 Components For FP
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Steve Easton said:
Be advised that scripts such as this are very CPU intensive.
If you modify it to handle multiple images it can easily drive a 500 / 600 mhz CPU to 100% and cause
the machine / browser to freeze

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
.......................with a computer

Hai Nguyen said:
Hi
I have the falling snow code, but instead of snow, I want to put my pictures
there. Therefore, the website will have random pictures falling (It's pretty
cool, I think). Can anyone help me?

The third line from the <!-- Begin is to put the falling snow dir


<script language=JavaScript1.2>

//START "FALLING STARS"

<!-- Begin

var no = 21;
var speed = 18;
var snowflake = "image/snow.gif";
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;

var dx, xp, yp;
var am, stx, sty;
var i, doc_width = 800, doc_height = 600;

if (ns4up) {

doc_width = self.innerWidth;

doc_height = self.innerHeight;

} else if (ie4up) {

doc_width = document.body.clientWidth;

doc_height = document.body.clientHeight;

}

dx = new Array();

xp = new Array();

yp = new Array();

am = new Array();

stx = new Array();

sty = new Array();

for (i = 0; i < no; ++ i) {

dx = 0;
xp = Math.random()*(doc_width-50);

yp = Math.random()*doc_height;

am = Math.random()*20;
stx = 0.02 + Math.random()/10;
sty = 0.7 + Math.random();
if (ns4up) {
if (i == 0) {

document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");

document.write("top=\"15\" visibility=\"show\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></layer>");

} else {

document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");

document.write("top=\"15\" visibility=\"show\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></layer>");

}

} else if (ie4up) {

if (i == 0) {

document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");

document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");

document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></div>");

} else {

document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");

document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");

document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></div>");

}

}

}

function snowNS() {
for (i = 0; i < no; ++ i) {
yp += sty;

if (yp > doc_height-50) {

xp = Math.random()*(doc_width-am-30);

yp = 0;

stx = 0.02 + Math.random()/10;

sty = 0.7 + Math.random();

doc_width = self.innerWidth;

doc_height = self.innerHeight;

}

dx += stx;

document.layers["dot"+i].top = yp;

document.layers["dot"+i].left = xp + am*Math.sin(dx);

}

setTimeout("snowNS()", speed);

}

function snowIE() {
for (i = 0; i < no; ++ i) {
yp += sty;

if (yp > doc_height-50) {

xp = Math.random()*(doc_width-am-30);

yp = 0;

stx = 0.02 + Math.random()/10;

sty = 0.7 + Math.random();

doc_width = document.body.clientWidth;

doc_height = document.body.clientHeight;

}

dx += stx;

document.all["dot"+i].style.pixelTop = yp;

document.all["dot"+i].style.pixelLeft = xp + am*Math.sin(dx);

}

setTimeout("snowIE()", speed);

}

if (ns4up) {

snowNS();

} else if (ie4up) {

snowIE();

}
// End -->
//END "FALLING STARS"
</SCRIPT>


THANK YOU VERY MUCH

 
S

Steve Easton

Surprisingly, a similar script that uses 4 different images will make a 550 mhz processor go to 100%
utilization.
I thought it was graphics driver issue also, until I opened task manager and saw that the CPU was
maxed at 100%.



--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer

MD Websunlimited said:
Really, this seems a little over stated. The problem would more than likely be the graphic processor and not the CPU.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 102 Components For FP
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Be advised that scripts such as this are very CPU intensive.
If you modify it to handle multiple images it can easily drive a 500 / 600 mhz CPU to 100% and cause
the machine / browser to freeze

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
.......................with a computer

Hi
I have the falling snow code, but instead of snow, I want to put my pictures
there. Therefore, the website will have random pictures falling (It's pretty
cool, I think). Can anyone help me?

The third line from the <!-- Begin is to put the falling snow dir


<script language=JavaScript1.2>

//START "FALLING STARS"

<!-- Begin

var no = 21;
var speed = 18;
var snowflake = "image/snow.gif";
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;

var dx, xp, yp;
var am, stx, sty;
var i, doc_width = 800, doc_height = 600;

if (ns4up) {

doc_width = self.innerWidth;

doc_height = self.innerHeight;

} else if (ie4up) {

doc_width = document.body.clientWidth;

doc_height = document.body.clientHeight;

}

dx = new Array();

xp = new Array();

yp = new Array();

am = new Array();

stx = new Array();

sty = new Array();

for (i = 0; i < no; ++ i) {

dx = 0;
xp = Math.random()*(doc_width-50);

yp = Math.random()*doc_height;

am = Math.random()*20;
stx = 0.02 + Math.random()/10;
sty = 0.7 + Math.random();
if (ns4up) {
if (i == 0) {

document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");

document.write("top=\"15\" visibility=\"show\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></layer>");

} else {

document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");

document.write("top=\"15\" visibility=\"show\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></layer>");

}

} else if (ie4up) {

if (i == 0) {

document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");

document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");

document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></div>");

} else {

document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");

document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");

document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");

document.write(snowflake + "\" border=\"0\"></div>");

}

}

}

function snowNS() {
for (i = 0; i < no; ++ i) {
yp += sty;

if (yp > doc_height-50) {

xp = Math.random()*(doc_width-am-30);

yp = 0;

stx = 0.02 + Math.random()/10;

sty = 0.7 + Math.random();

doc_width = self.innerWidth;

doc_height = self.innerHeight;

}

dx += stx;

document.layers["dot"+i].top = yp;

document.layers["dot"+i].left = xp + am*Math.sin(dx);

}

setTimeout("snowNS()", speed);

}

function snowIE() {
for (i = 0; i < no; ++ i) {
yp += sty;

if (yp > doc_height-50) {

xp = Math.random()*(doc_width-am-30);

yp = 0;

stx = 0.02 + Math.random()/10;

sty = 0.7 + Math.random();

doc_width = document.body.clientWidth;

doc_height = document.body.clientHeight;

}

dx += stx;

document.all["dot"+i].style.pixelTop = yp;

document.all["dot"+i].style.pixelLeft = xp + am*Math.sin(dx);

}

setTimeout("snowIE()", speed);

}

if (ns4up) {

snowNS();

} else if (ie4up) {

snowIE();

}
// End -->
//END "FALLING STARS"
</SCRIPT>


THANK YOU VERY MUCH


 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top