<html>
<body>
<script language="Javascript" type="text/javascript">
<!--hide
//STEP 1: PUT THIS CODE INTO THE HEAD OF YOUR DOCUMENT
var wdmax=300; //set maximum width of square image (px)
var wdmin=0; //set minimum thickness of edge-on image (px)
var inc=5; //set step change in px (wdmax-wdmin must be a multiple) )These two variables
var rate = 50; //pause between steps (in millisec) )determine flip-flop speed
var pause = 1000; //pause between flip and flop (in millisec)
var ff="flip"; //initialise whether movement starts with a "flip" (sideways) or "flop" (vertical) change.
function flipflop() {
if (ff=="flip") {
var wd = document.getElementById("pic").getAttribute("width");
wd = wd - inc;
document.getElementById("pic").setAttribute("width",wd);
if (wd==wdmin) {
document.getElementById("pic").setAttribute("src","http://img69.imageshack.us/img69/571/fupro.th.jpg"); //substitute name of your second picture
inc=-inc;
}
if (wd==wdmax) {
ff="flop";
inc=-inc;
setTimeout("flipflop()",pause);
}
else {
setTimeout("flipflop()",rate);
}
}
else {
var ht = document.getElementById("pic").getAttribute("height");
ht = ht - inc;
document.getElementById("pic").setAttribute("height",ht);
if (ht==wdmin) {
document.getElementById("pic").setAttribute("src","http://img48.imageshack.us/img48/9489/saleen32gw.jpg"); //substitute name of your first picture
inc=-inc;
}
if (ht==wdmax) {
ff="flip";
inc=-inc;
setTimeout("flipflop()",pause);
}
else {
setTimeout("flipflop()",rate);
}
}
}
<!-- STEP TWO: Insert the onload event handler into your BODY tag -->
<BODY onload="javascript:flipflop()">
<!-- STEP THREE: Copy this code into the BODY of your HTML document -->
<center>
<TABLE border="0">
<th width="160" height="160">
<IMG src="pic1.gif" width="120" height="120" ID="pic">
</th></TABLE>
<!-- Script Size: 3.54 KB -->
<HEAD>
<script LANGUAGE="Javascript">
<!--hide
//STEP 1: PUT THIS CODE INTO THE HEAD OF YOUR DOCUMENT
var wdmax=300; //set maximum width of square image (px)
var wdmin=0; //set minimum thickness of edge-on image (px)
var inc=5; //set step change in px (wdmax-wdmin must be a multiple) )These two variables
var rate = 50; //pause between steps (in millisec) )determine flip-flop speed
var pause = 1000; //pause between flip and flop (in millisec)
var ff="flip"; //initialise whether movement starts with a "flip" (sideways) or "flop" (vertical) change.
function flipflop() {
if (ff=="flip") {
var wd = document.getElementById("pic").getAttribute("width");
wd = wd - inc;
document.getElementById("pic").setAttribute("width",wd);
if (wd==wdmin) {
document.getElementById("pic").setAttribute("src","http://img69.imageshack.us/img69/571/fupro.th.jpg"); //substitute name of your second picture
inc=-inc;
}
if (wd==wdmax) {
ff="flop";
inc=-inc;
setTimeout("flipflop()",pause);
}
else {
setTimeout("flipflop()",rate);
}
}
else {
var ht = document.getElementById("pic").getAttribute("height");
ht = ht - inc;
document.getElementById("pic").setAttribute("height",ht);
if (ht==wdmin) {
document.getElementById("pic").setAttribute("src","http://img48.imageshack.us/img48/9489/saleen32gw.jpg"); //substitute name of your first picture
inc=-inc;
}
if (ht==wdmax) {
ff="flip";
inc=-inc;
setTimeout("flipflop()",pause);
}
else {
setTimeout("flipflop()",rate);
}
}
}
<!-- Begin
var isNS = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4));
var _all = '';
var _style = '';
var wwidth, wheight;
var ydir = '++';
var xdir = '++';
var id1, id2, id3;
var x = 1;
var y = 1;
var x1, y1;
if(!isNS) {
_all='all.';
_style='.style';
}
function getwindowsize() {
clearTimeout(id1);
clearTimeout(id2);
clearTimeout(id3);
if (isNS) {
wwidth = window.innerWidth - 55;
wheight = window.innerHeight - 50;
} else {
wwidth = document.body.clientWidth - 55;
wheight = document.body.clientHeight - 50;
}
id3 = setTimeout('randomdir()', 20000);
animate();
}
function randomdir() {
if (Math.floor(Math.random()*2)) {
(Math.floor(Math.random()*2)) ? xdir='--': xdir='++';
} else {
(Math.floor(Math.random()*2)) ? ydir='--': ydir='++';
}
id2 = setTimeout('randomdir()', 20000);
}
function animate() {
eval('x'+xdir);
eval('y'+ydir);
if (isNS) {
pic1.moveTo((x+pageXOffset),(y+pageYOffset))
} else {
pic1.pixelLeft = x+document.body.scrollLeft;
pic1.pixelTop = y+document.body.scrollTop;
}
if (isNS) {
if (pic1.top <= 5+pageYOffset) ydir = '++';
if (pic1.top >= wheight+pageYOffset) ydir = '--';
if (pic1.left >= wwidth+pageXOffset) xdir = '--';
if (pic1.left <= 5+pageXOffset) xdir = '++';
} else {
if (pic1.pixelTop <= 5+document.body.scrollTop) ydir = '++';
if (pic1.pixelTop >= wheight+document.body.scrollTop) ydir = '--';
if (pic1.pixelLeft >= wwidth+document.body.scrollLeft) xdir = '--';
if (pic1.pixelLeft <= 5+document.body.scrollLeft) xdir = '++';
}
id1 = setTimeout('animate()', 30);
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Insert the event handlers into your BODY tag -->
<BODY onload="getwindowsize()" onresize="getwindowsize()" background="space.jpg">
<!-- STEP THREE: Copy this code into the BODY of your HTML document -->
<div id="pic1" style="position:absolute; visibility:visible; left:0px; top:0px; z-index:-1">
<img src= "http://www.mira.org/fts0/planets/102/images/halebopp.jpg"
width="325" height="250">
</div>
<script language="javascript">
var pic1=eval('document.'+_all+'pic1'+_style);
</script>
</HEAD>
</body>
</html>
Two ScriptsI need help getting these two scripts working at the same time
Page 1 of 1
1 Replies - 1204 Views - Last Post: 27 March 2010 - 03:35 PM
#1
Two Scripts
Posted 26 March 2010 - 12:21 PM
I need help getting these two scripts working at the same time.Any help with the code would be greatly appreciated!!
Replies To: Two Scripts
#2
Re: Two Scripts
Posted 27 March 2010 - 03:35 PM
A+++++, on 26 March 2010 - 11:21 AM, said:
I need help getting these two scripts working at the same time.Any help with the code would be greatly appreciated!!
<html>
<body>
<script language="Javascript" type="text/javascript">
<!--hide
//STEP 1: PUT THIS CODE INTO THE HEAD OF YOUR DOCUMENT
var wdmax=300; //set maximum width of square image (px)
var wdmin=0; //set minimum thickness of edge-on image (px)
var inc=5; //set step change in px (wdmax-wdmin must be a multiple) )These two variables
var rate = 50; //pause between steps (in millisec) )determine flip-flop speed
var pause = 1000; //pause between flip and flop (in millisec)
var ff="flip"; //initialise whether movement starts with a "flip" (sideways) or "flop" (vertical) change.
function flipflop() {
if (ff=="flip") {
var wd = document.getElementById("pic").getAttribute("width");
wd = wd - inc;
document.getElementById("pic").setAttribute("width",wd);
if (wd==wdmin) {
document.getElementById("pic").setAttribute("src","http://img69.imageshack.us/img69/571/fupro.th.jpg"); //substitute name of your second picture
inc=-inc;
}
if (wd==wdmax) {
ff="flop";
inc=-inc;
setTimeout("flipflop()",pause);
}
else {
setTimeout("flipflop()",rate);
}
}
else {
var ht = document.getElementById("pic").getAttribute("height");
ht = ht - inc;
document.getElementById("pic").setAttribute("height",ht);
if (ht==wdmin) {
document.getElementById("pic").setAttribute("src","http://img48.imageshack.us/img48/9489/saleen32gw.jpg"); //substitute name of your first picture
inc=-inc;
}
if (ht==wdmax) {
ff="flip";
inc=-inc;
setTimeout("flipflop()",pause);
}
else {
setTimeout("flipflop()",rate);
}
}
}
<!-- STEP TWO: Insert the onload event handler into your BODY tag -->
<BODY onload="javascript:flipflop()">
<!-- STEP THREE: Copy this code into the BODY of your HTML document -->
<center>
<TABLE border="0">
<th width="160" height="160">
<IMG src="pic1.gif" width="120" height="120" ID="pic">
</th></TABLE>
<!-- Script Size: 3.54 KB -->
<HEAD>
<script LANGUAGE="Javascript">
<!--hide
//STEP 1: PUT THIS CODE INTO THE HEAD OF YOUR DOCUMENT
var wdmax=300; //set maximum width of square image (px)
var wdmin=0; //set minimum thickness of edge-on image (px)
var inc=5; //set step change in px (wdmax-wdmin must be a multiple) )These two variables
var rate = 50; //pause between steps (in millisec) )determine flip-flop speed
var pause = 1000; //pause between flip and flop (in millisec)
var ff="flip"; //initialise whether movement starts with a "flip" (sideways) or "flop" (vertical) change.
function flipflop() {
if (ff=="flip") {
var wd = document.getElementById("pic").getAttribute("width");
wd = wd - inc;
document.getElementById("pic").setAttribute("width",wd);
if (wd==wdmin) {
document.getElementById("pic").setAttribute("src","http://img69.imageshack.us/img69/571/fupro.th.jpg"); //substitute name of your second picture
inc=-inc;
}
if (wd==wdmax) {
ff="flop";
inc=-inc;
setTimeout("flipflop()",pause);
}
else {
setTimeout("flipflop()",rate);
}
}
else {
var ht = document.getElementById("pic").getAttribute("height");
ht = ht - inc;
document.getElementById("pic").setAttribute("height",ht);
if (ht==wdmin) {
document.getElementById("pic").setAttribute("src","http://img48.imageshack.us/img48/9489/saleen32gw.jpg"); //substitute name of your first picture
inc=-inc;
}
if (ht==wdmax) {
ff="flip";
inc=-inc;
setTimeout("flipflop()",pause);
}
else {
setTimeout("flipflop()",rate);
}
}
}
<!-- Begin
var isNS = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4));
var _all = '';
var _style = '';
var wwidth, wheight;
var ydir = '++';
var xdir = '++';
var id1, id2, id3;
var x = 1;
var y = 1;
var x1, y1;
if(!isNS) {
_all='all.';
_style='.style';
}
function getwindowsize() {
clearTimeout(id1);
clearTimeout(id2);
clearTimeout(id3);
if (isNS) {
wwidth = window.innerWidth - 55;
wheight = window.innerHeight - 50;
} else {
wwidth = document.body.clientWidth - 55;
wheight = document.body.clientHeight - 50;
}
id3 = setTimeout('randomdir()', 20000);
animate();
}
function randomdir() {
if (Math.floor(Math.random()*2)) {
(Math.floor(Math.random()*2)) ? xdir='--': xdir='++';
} else {
(Math.floor(Math.random()*2)) ? ydir='--': ydir='++';
}
id2 = setTimeout('randomdir()', 20000);
}
function animate() {
eval('x'+xdir);
eval('y'+ydir);
if (isNS) {
pic1.moveTo((x+pageXOffset),(y+pageYOffset))
} else {
pic1.pixelLeft = x+document.body.scrollLeft;
pic1.pixelTop = y+document.body.scrollTop;
}
if (isNS) {
if (pic1.top <= 5+pageYOffset) ydir = '++';
if (pic1.top >= wheight+pageYOffset) ydir = '--';
if (pic1.left >= wwidth+pageXOffset) xdir = '--';
if (pic1.left <= 5+pageXOffset) xdir = '++';
} else {
if (pic1.pixelTop <= 5+document.body.scrollTop) ydir = '++';
if (pic1.pixelTop >= wheight+document.body.scrollTop) ydir = '--';
if (pic1.pixelLeft >= wwidth+document.body.scrollLeft) xdir = '--';
if (pic1.pixelLeft <= 5+document.body.scrollLeft) xdir = '++';
}
id1 = setTimeout('animate()', 30);
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Insert the event handlers into your BODY tag -->
<BODY onload="getwindowsize()" onresize="getwindowsize()" background="space.jpg">
<!-- STEP THREE: Copy this code into the BODY of your HTML document -->
<div id="pic1" style="position:absolute; visibility:visible; left:0px; top:0px; z-index:-1">
<img src= "http://www.mira.org/fts0/planets/102/images/halebopp.jpg"
width="325" height="250">
</div>
<script language="javascript">
var pic1=eval('document.'+_all+'pic1'+_style);
</script>
</HEAD>
</body>
</html>
You have two script elements that need to be placed in between the head tag, and one of your script elements doesn't even have a closing tag. The rest needs to be placed in the body of the document. Here is what the code will look like after you do all that:
<html>
<body>
<script language="Javascript" type="text/javascript">
<!--hide
//STEP 1: PUT THIS CODE INTO THE HEAD OF YOUR DOCUMENT
var wdmax=300; //set maximum width of square image (px)
var wdmin=0; //set minimum thickness of edge-on image (px)
var inc=5; //set step change in px (wdmax-wdmin must be a multiple) )These two variables
var rate = 50; //pause between steps (in millisec) )determine flip-flop speed
var pause = 1000; //pause between flip and flop (in millisec)
var ff="flip"; //initialise whether movement starts with a "flip" (sideways) or "flop" (vertical) change.
function flipflop() {
if (ff=="flip") {
var wd = document.getElementById("pic").getAttribute("width");
wd = wd - inc;
document.getElementById("pic").setAttribute("width",wd);
if (wd==wdmin) {
document.getElementById("pic").setAttribute("src","http://img69.imageshack.us/img69/571/fupro.th.jpg"); //substitute name of your second picture
inc=-inc;
}
if (wd==wdmax) {
ff="flop";
inc=-inc;
setTimeout("flipflop()",pause);
}
else {
setTimeout("flipflop()",rate);
}
}
else {
var ht = document.getElementById("pic").getAttribute("height");
ht = ht - inc;
document.getElementById("pic").setAttribute("height",ht);
if (ht==wdmin) {
document.getElementById("pic").setAttribute("src","http://img48.imageshack.us/img48/9489/saleen32gw.jpg"); //substitute name of your first picture
inc=-inc;
}
if (ht==wdmax) {
ff="flip";
inc=-inc;
setTimeout("flipflop()",pause);
}
else {
setTimeout("flipflop()",rate);
}
}
}
// End Hiding -->
</script>
<script LANGUAGE="Javascript">
<!--hide
//STEP 1: PUT THIS CODE INTO THE HEAD OF YOUR DOCUMENT
var wdmax=300; //set maximum width of square image (px)
var wdmin=0; //set minimum thickness of edge-on image (px)
var inc=5; //set step change in px (wdmax-wdmin must be a multiple) )These two variables
var rate = 50; //pause between steps (in millisec) )determine flip-flop speed
var pause = 1000; //pause between flip and flop (in millisec)
var ff="flip"; //initialise whether movement starts with a "flip" (sideways) or "flop" (vertical) change.
function flipflop() {
if (ff=="flip") {
var wd = document.getElementById("pic").getAttribute("width");
wd = wd - inc;
document.getElementById("pic").setAttribute("width",wd);
if (wd==wdmin) {
document.getElementById("pic").setAttribute("src","http://img69.imageshack.us/img69/571/fupro.th.jpg"); //substitute name of your second picture
inc=-inc;
}
if (wd==wdmax) {
ff="flop";
inc=-inc;
setTimeout("flipflop()",pause);
}
else {
setTimeout("flipflop()",rate);
}
}
else {
var ht = document.getElementById("pic").getAttribute("height");
ht = ht - inc;
document.getElementById("pic").setAttribute("height",ht);
if (ht==wdmin) {
document.getElementById("pic").setAttribute("src","http://img48.imageshack.us/img48/9489/saleen32gw.jpg"); //substitute name of your first picture
inc=-inc;
}
if (ht==wdmax) {
ff="flip";
inc=-inc;
setTimeout("flipflop()",pause);
}
else {
setTimeout("flipflop()",rate);
}
}
}
<!-- Begin
var isNS = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4));
var _all = '';
var _style = '';
var wwidth, wheight;
var ydir = '++';
var xdir = '++';
var id1, id2, id3;
var x = 1;
var y = 1;
var x1, y1;
if(!isNS) {
_all='all.';
_style='.style';
}
function getwindowsize() {
clearTimeout(id1);
clearTimeout(id2);
clearTimeout(id3);
if (isNS) {
wwidth = window.innerWidth - 55;
wheight = window.innerHeight - 50;
} else {
wwidth = document.body.clientWidth - 55;
wheight = document.body.clientHeight - 50;
}
id3 = setTimeout('randomdir()', 20000);
animate();
}
function randomdir() {
if (Math.floor(Math.random()*2)) {
(Math.floor(Math.random()*2)) ? xdir='--': xdir='++';
} else {
(Math.floor(Math.random()*2)) ? ydir='--': ydir='++';
}
id2 = setTimeout('randomdir()', 20000);
}
function animate() {
eval('x'+xdir);
eval('y'+ydir);
if (isNS) {
pic1.moveTo((x+pageXOffset),(y+pageYOffset))
} else {
pic1.pixelLeft = x+document.body.scrollLeft;
pic1.pixelTop = y+document.body.scrollTop;
}
if (isNS) {
if (pic1.top <= 5+pageYOffset) ydir = '++';
if (pic1.top >= wheight+pageYOffset) ydir = '--';
if (pic1.left >= wwidth+pageXOffset) xdir = '--';
if (pic1.left <= 5+pageXOffset) xdir = '++';
} else {
if (pic1.pixelTop <= 5+document.body.scrollTop) ydir = '++';
if (pic1.pixelTop >= wheight+document.body.scrollTop) ydir = '--';
if (pic1.pixelLeft >= wwidth+document.body.scrollLeft) xdir = '--';
if (pic1.pixelLeft <= 5+document.body.scrollLeft) xdir = '++';
}
id1 = setTimeout('animate()', 30);
}
// End -->
//End hiding -->
</script>
</head>
<BODY onload="javascript:flipflop();getwindowsize();" onresize=”getwindowsize();” background=”space.jpg”>
<center>
<TABLE border="0">
<th width="160" height="160">
<IMG src="pic1.gif" width="120" height="120" ID="pic">
</th></TABLE>
<div id="pic1" style="position:absolute; visibility:visible; left:0px; top:0px; z-index:-1">
<img src= "http://www.mira.org/fts0/planets/102/images/halebopp.jpg"
width="325" height="250">
</div>
<script language="javascript">
var pic1=eval('document.'+_all+'pic1'+_style);
</script>
</body>
</html>
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|