/    Sign up×
Community /Pin to ProfileBookmark

2 scripts running at once

hi everyone

i have two scripts running on the same page below. the first script runs fine and then the second script does’nt run at all. what is going on ca n e 1 help. what i wan to happen is the first script runs and then the second script runs . i don’t know much about javascripts but i really want this effect can n e 1 help?

<QUOTE>

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<title>Divine Onkar Mission (Duty Of Mankind) – Offical Website</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
</head>

<body bgcolor=”black”>

<script language=”JavaScript”>
<!– Fade Link script
Location=’mailto:[email protected]‘ //Enter your link here.
Img=new Image();
Img.src=”logoHeader.jpg”; //Pre-load your image.
ImageName=”logoHeader.jpg”; //Your image name, same as above.
S=null;
fadeStep = 3;
fade = 70;
currentStep=0;
step = 1;
x=300;
y=300;
function Expand(){
if (document.all){
y=window.document.body.clientHeight-80 +document.body.scrollTop;
x=window.document.body.clientWidth-80;
pic.height=currentStep*3;
pic.width=currentStep*
11;
pic.style.top=y+(-currentStep);
pic.style.left=x+(-currentStep);
pic.style.filter=’alpha(opacity=’+fade+’)’;
currentStep+=step;
if (currentStep > 60) fade-=fadeStep;
if (fade < -20) {currentStep=0;fade=0;}
S=setTimeout(‘Expand()’,70);
}
}
if (document.all){
document.write(‘<div style=”position:absolute;top:-400px;left:-750px”>’);
document.write(‘<div style=”position:relative”>’);
document.write(‘<a href=”‘+Location+'”>’
+'<img id=”pic” src=”‘+ImageName+'” border=”0″ style=”position:absolute;top:20000px;left:20000px”></a>’);
document.write(‘</div></div>’);
}
if (document.all)
window.onload=Expand;
//–>
</script>

<script language=”JavaScript”>
<!– picture slide script
a=new Image();a.src=”logoHeader.jpg”;
b=new Image();b.src=”Hut.JPG”;
c=new Image();c.src=”SickMother_bw.jpg”;
d=new Image();d.src=”hospital.jpg”;

function startSlideShow(){setTimeout(“pic1()”,2000);}
function pic1(){document.images.slidepix.src=”logoHeader.jpg”;
setTimeout(“pic2()”,2000);}
function pic2(){document.images.slidepix.src=”Hut.JPG”;
setTimeout(“pic3()”,2000);}
function pic3(){document.images.slidepix.src=”SickMother_bw.jpg”;
setTimeout(“pic4()”,2000);}
function pic4(){document.images.slidepix.src=”hospital.jpg”;
setTimeout(“pic1()”,2000);}

//–>
</script>

</body>
</html>

</QUOTE>

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@soccer362001Feb 02.2004 — You may try putting your scripts in the <head> tag.
Copy linkTweet thisAlerts:
@goofballFeb 02.2004 — Yes, put them in the HEAD tag.

I think another problem may be that you're not calling the functions you define in the second script.

In the BODY tag, try putting:

[FONT=courier new][B]onLoad="startSlideShow();"[/B][/FONT]

Hope that helps.
Copy linkTweet thisAlerts:
@evilz35authorFeb 02.2004 — i've tried doing both of these things but they don't work
Copy linkTweet thisAlerts:
@goofballFeb 02.2004 — First, make sure all your images are referenced to the right place. The URLs you're using will only work if the image files are in the same folder as the HTML page.

ex: [B]

imgA = new Image(); imgA.src = "../images/logoHeader.jpg";

imgB = new Image(); imgB.src = "http://www.yoursite.com/images/Hut.JPG";

imgC = new Image(); imgC.src = "images/SickMother_bw.jpg";

imgD = new Image(); imgD.src = "../images/hospital.jpg";

[/B]


next, in stead of naming the image file's path in your pic1(), pic3(), etc. functions, you have to name the variable that you assigned that source to:

[B]document.images.slidepix.src="logoHeader.jpg";[/B]

changes to

[B]document.images.slidepix.src = imgA;[/B]

Finally, make sure that the image "slidepix" has a properly referenced name

<img src=".../whatever.jpg" [B]id="slidepix"[/B]>

I like to reference the images with a more cross-browser friendly approach:

document.getElementById('slidepix').src = imgA;

FYI - there used to be some decent JavaScript tutorials on www.htmlgoodies.com - if they are still there, you may find them useful.

Cheers
×

Success!

Help @evilz35 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...