FutureQuest, Inc. FutureQuest, Inc. FutureQuest, Inc.

FutureQuest, Inc.
Go Back   FutureQuest Community > General Site Owner Support (All may read/respond) > General Coding/Development
User Name
Password  Lost PW

Reply
 
Thread Tools Search this Thread Display Modes
Old 02-26-2002, 03:57 PM   Postid: 62671
morrisdan1
Registered User

Forum Notability:
75 pts: Helpful Contributor
[Post Feedback]
 
Join Date: Dec 2000
Posts: 214
Javascript Conflicts between these codes?

Hello everyone,

The following javascript codes will not work on the same page. I do not believe the codes are the problem. Since they both work when not being placed on the same page. The top codes rotates an image. And the bottom codes rotates texts.

The image rotater codes does not work when being placed on the same page as the codes for the text rotater.

I suspect it may have something to do with Javascript conflict as explained in the following page:

http://javascriptkit.com/javatutors/multiplejava2.shtml

But can't seem to pinpoint the problem nor could I figure out how to possibly fix the problem ?

Comments, Suggestions anyone ?

I'd really appreciate it. Thanks !

<script language="javascript">
<!--

/*
Script by FPMC at http://jsarchive.8m.com
Submitted to JavaScript Kit (http://javascriptkit.com)
For this and 400+ free scripts, visit http://javascriptkit.com
*/

//set image paths
src = ["image1gif", "image2.gif", "image3.gif"]

//set corresponding urls
url = ["link1.html",
"link2.html",
"link3.html"]

//set duration for each image
duration = 2;

//Please do not edit below
ads=[];
ct=0;

function switchAd() {
var n=(ct+1)%src.length;
if (ads[n] && (ads[n].complete || ads[n].complete==null)) {
document["Ad_Image"].src = ads[ct=n].src;
}
ads[n=(ct+1)%src.length] = new Image;
ads[n].src = src[n];
setTimeout("switchAd()",duration*1000);
}

function doLink(){
location.href = url[ct];
}

onload = function(){
if (document.images)
switchAd();
}
//-->
</script>

<script type="text/javascript" language="Javascript1.2">
<!-- // Hide

// STEP TWO: change message HTML here
var startHTML = "<center><font color=800000 size=+1><b>"
var endHTML = "</b></font></center>"
var rotateSpeed = 960 // set rotate speed in milliseconds

var myData=new Array()
// STEP THREE: change or add your own message's here
myData[0] = "Topic One"
myData[1] = "Topic Two"
myData[2] = "Topic Three"

// End user modifiable variables
if (document.layers) {
document.write('<ilayer id="NS4message" height=25 width=100%><layer id="NS4message2" height=25 width=100%></layer></ilayer>') temp='document.NS4message.document.NS4message2.document.write(sta rtHTML+myData[cnt++]+endHTML);'+ 'document.NS4message.document.NS4message2.document.close()'
}
else if (document.getElementById) {
document.write(startHTML+'<div id="message" style="position:relative;">IE division</div>'+endHTML)
temp='document.getElementById("message").firstChild.nodeValue=myD ata[cnt++]'
}
else if (document.all) {
document.write(startHTML+'<div id="message" style="position:relative;">IE division</div>'+endHTML)
temp='message.innerHTML=myData[cnt++]'
}
var cnt=0
function rotate(){
eval(temp)
if (cnt==myData.length) cnt=0
setTimeout("rotate()",rotateSpeed)
}
window.onload=rotate
// -->
</script>
morrisdan1 is offline   Reply With Quote
Old 02-27-2002, 12:24 AM   Postid: 62716
kitchin
Site Owner

Forum Notability:
1163 pts: A True Crowd-pleaser!
[Post Feedback]
 
Join Date: Jan 2001
Location: Virginia
Posts: 2,992
Both script parts set "window.onload".

Try this:

Code:
...
// onload = function(){ // comment out this line
function myload1() {  // replace with new name
  if (document.images) 
    switchAd(); 
} 
...
// window.onload=rotate // comment out this line
// Add these lines:
function myload2() {
  myload1();
  rotate();
}
Then change your <BODY> tag like this:
from:
<BODY ...>
to
<BODY onload="myload2()" ...>

That seems better than messing around with assigning to "window.onload" in the script anyway.
kitchin is offline   Reply With Quote
Old 02-27-2002, 01:51 PM   Postid: 62767
morrisdan1
Registered User

Forum Notability:
75 pts: Helpful Contributor
[Post Feedback]
 
Join Date: Dec 2000
Posts: 214
kitchin,

That did the trick ! The only thing is that I took out the myload1() parameter from the following function as to that it wasn't needed in there:

function myload2() {
rotate();
}

Otherwise, it's keep up the good work. Thanks, I appreciate it !

Sincerely,
--Dan
morrisdan1 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 visitors)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 04:22 AM.


Running on vBulletin®
Copyright © 2000 - 2013, Jelsoft Enterprises Ltd.
Hosted & Administrated by FutureQuest, Inc.
Images & content copyright © 1998-2013 FutureQuest, Inc.
FutureQuest, Inc.