473,326 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Need help with script conflict (Two scripts on one page)

This is my first post. I hope I don't sound stupid.
I have a script conflict when I put two scripts on one page. Both scripts
will work if I use one at a time but the menu button script will not work
when I add the scrolling text script. One script, the menu button script,
has an "Onload" command and the other one does not. From what I know, and
that's not much, I need to put both scripts in the "Onload" command. I just
don't know how to write the script for the scrolling text because it doesn't
use the "Onload" command. Here is the script I'm using. If anyone has a fix,
I thank you much.

Pat

IN THE HEAD.......

<title>Recipe 10.8</title>

<style id="main" type="text/css">

body {background-color:#eeeeee; font-family:Arial,Helvetica,sans-serif;
font-size:12px;}

h1 {font-size:2.0em; font-weight:bold}

</style>

<link rel="stylesheet" href="menus.css" type="text/css" />

<script language="JavaScript" type="text/javascript"
src="menus.js"></script>

IN THE BODY FOR THE MENU BUTTONS..........

<body onload="initMenus()">

<div id="menubar" align="left"><left>

<table border="0" width="100">

<tr>

<td>

<a href="index.html"><img id="menuImg_1" class="menuImg"

src="_images/home.gif" border="0" height="20"

width="125"></td>

</tr>

<tr>

<td><a href="heritage.html"><img id="menuImg_2"

class="menuImg" src="_images/heritage.gif" border="0" height="20"

width="125"></td></tr>

<tr>

<td><a href="ministries.html"><img id="menuImg_3"

class="menuImg" src="_images/ministries.gif" border="0"

height="20" width="125"></td></tr>

<tr>

<td><a href="missionaries.html"><img id="menuImg_4"

class="menuImg" src="_images/missionaries.gif" border="0"

height="20" width="125"></td></tr>

<tr>

<td><a href="calendar.html"><img id="menuImg_5"

class="menuImg" src="_images/calendar.gif" border="0"

height="20" width="125"></td></tr>

<tr>

<td><a href="feedback.html"><img id="menuImg_6"

class="menuImg" src="_images/feedback.gif" border="0"

height="20" width="125"></td></tr>

<tr>

<td><a href="contact.html"><img id="menuImg_7"

class="menuImg" src="_images/contact.gif" border="0"

height="20" width="125"></td></tr>

<tr>

<td><a href="Directory/directory.html"><img id="menuImg_8"

class="menuImg" src="_images/directory.gif" border="0"

height="20" width="125"></td></tr>

</table

</left>

</div>

IN THE BODY FOR THE SCROLLING TEXT..............

<script type="text/javascript">

/***********************************************

* Pausing updown message scroller- © Dynamic Drive DHTML code library
(www.dynamicdrive.com)

* This notice MUST stay intact for legal use

* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code

***********************************************/

//configure the below five variables to change the style of the scroller

var scrollerdelay='6000' //delay between msg scrolls. 3000=3 seconds.

var scrollerwidth='200px'

var scrollerheight='220px'

var scrollerbgcolor=''

//set below to '' if you don't wish to use a background image

var scrollerbackground="yes"

//configure the below variable to change the contents of the scroller

var messages=new Array()

messages[0]="<font face='Arial'><BR><BR><B>Welcome to Faith Calvary
Church</B></font>"

messages[1]="<font face='Arial'><B>Information in this area will be updated
often.</B></font>"

messages[2]="<font face='Arial'><B><BR>Come back often for more
information</B></font>"

///////Do not edit pass this line///////////////////////

var ie=document.all

var dom=document.getElementById

if (messages.length>2)

i=2

else

i=0

function move1(whichlayer){

tlayer=eval(whichlayer)

if (tlayer.top>0&&tlayer.top<=5){

tlayer.top=0

setTimeout("move1(tlayer)",scrollerdelay)

setTimeout("move2(document.main.document.second)", scrollerdelay)

return

}

if (tlayer.top>=tlayer.document.height*-1){

tlayer.top-=5

setTimeout("move1(tlayer)",50)

}

else{

tlayer.top=parseInt(scrollerheight)

tlayer.document.write(messages[i])

tlayer.document.close()

if (i==messages.length-1)

i=0

else

i++

}

}

function move2(whichlayer){

tlayer2=eval(whichlayer)

if (tlayer2.top>0&&tlayer2.top<=5){

tlayer2.top=0

setTimeout("move2(tlayer2)",scrollerdelay)

setTimeout("move1(document.main.document.first)",s crollerdelay)

return

}

if (tlayer2.top>=tlayer2.document.height*-1){

tlayer2.top-=5

setTimeout("move2(tlayer2)",50)

}

else{

tlayer2.top=parseInt(scrollerheight)

tlayer2.document.write(messages[i])

tlayer2.document.close()

if (i==messages.length-1)

i=0

else

i++

}

}

function move3(whichdiv){

tdiv=eval(whichdiv)

if (parseInt(tdiv.style.top)>0&&parseInt(tdiv.style.t op)<=5){

tdiv.style.top=0+"px"

setTimeout("move3(tdiv)",scrollerdelay)

setTimeout("move4(second2_obj)",scrollerdelay)

return

}

if (parseInt(tdiv.style.top)>=tdiv.offsetHeight*-1){

tdiv.style.top=parseInt(tdiv.style.top)-5+"px"

setTimeout("move3(tdiv)",50)

}

else{

tdiv.style.top=parseInt(scrollerheight)

tdiv.innerHTML=messages[i]

if (i==messages.length-1)

i=0

else

i++

}

}

function move4(whichdiv){

tdiv2=eval(whichdiv)

if (parseInt(tdiv2.style.top)>0&&parseInt(tdiv2.style .top)<=5){

tdiv2.style.top=0+"px"

setTimeout("move4(tdiv2)",scrollerdelay)

setTimeout("move3(first2_obj)",scrollerdelay)

return

}

if (parseInt(tdiv2.style.top)>=tdiv2.offsetHeight*-1){

tdiv2.style.top=parseInt(tdiv2.style.top)-5+"px"

setTimeout("move4(second2_obj)",50)

}

else{

tdiv2.style.top=parseInt(scrollerheight)

tdiv2.innerHTML=messages[i]

if (i==messages.length-1)

i=0

else

i++

}

}

function startscroll(){

if (ie||dom){

first2_obj=ie? first2 : document.getElementById("first2")

second2_obj=ie? second2 : document.getElementById("second2")

move3(first2_obj)

second2_obj.style.top=scrollerheight

second2_obj.style.visibility='visible'

}

else if (document.layers){

document.main.visibility='show'

move1(document.main.document.first)

document.main.document.second.top=parseInt(scrolle rheight)+5

document.main.document.second.visibility='show'

}

}

window.onload=startscroll

</script>

<ilayer id="main" width=&{scrollerwidth}; height=&{scrollerheight};
bgColor=&{scrollerbgcolor}; background=&{scrollerbackground};
visibility=hide>

<layer id="first" left=0 top=1 width=&{scrollerwidth};>

<script language="JavaScript1.2">

if (document.layers)

document.write(messages[0])

</script>

</layer>

<layer id="second" left=0 top=0 width=&{scrollerwidth}; visibility=hide>

<script language="JavaScript1.2">

if (document.layers)

document.write(messages[dyndetermine=(messages.length==1)? 0 : 1])

</script>

</layer>

</ilayer>

<script language="JavaScript1.2">

if (ie||dom){

document.writeln('<div id="main2"
style="position:relative;width:'+scrollerwidth+';h eight:'+scrollerheight+';overflow:hidden;backgroun d-color:'+scrollerbgcolor+'
;background-image:url('+scrollerbackground+')">')

document.writeln('<div
style="position:absolute;width:'+scrollerwidth+';h eight:'+scrollerheight+';clip:rect(0
'+scrollerwidth+' '+scrollerheight+' 0);left:0px;top:0px">')

document.writeln('<div id="first2"
style="position:absolute;width:'+scrollerwidth+';l eft:0px;top:1px;">')

document.write(messages[0])

document.writeln('</div>')

document.writeln('<div id="second2"
style="position:absolute;width:'+scrollerwidth+';l eft:0px;top:0px;visibility:hidden">')

document.write(messages[dyndetermine=(messages.length==1)? 0 : 1])

document.writeln('</div>')

document.writeln('</div>')

document.writeln('</div>')

}

</script>

Jul 23 '05 #1
3 1731
P Wolpert wrote:
From what I know, and
that's not much, I need to put both scripts in the "Onload" command. I just
don't know how to write the script for the scrolling text because it doesn't
use the "Onload" command.


You can run several functions from the onload-event by seperating them
with semi-colon:
<body onload="initMenus();startscroll();">

After that you can remove this line:
window.onload=startscroll
from the scroll-script.
Jul 23 '05 #2
JRS: In article <41***********************@news.sunsite.dk>, dated Mon,
20 Dec 2004 02:13:42, seen in news:comp.lang.javascript, Ulrik
Skovenborg <"skovenborg at frac dot dk"@?.?> posted :
P Wolpert wrote:
From what I know, and
that's not much, I need to put both scripts in the "Onload" command. I just
don't know how to write the script for the scrolling text because it doesn't
use the "Onload" command.


You can run several functions from the onload-event by seperating them
with semi-colon:
<body onload="initMenus();startscroll();">


Agreed. Some would prefer something like :-

<body onload="StartThemAll()">
....
function StartThemAll() {
initMenus()
startscroll() }

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #3
Thank you for your help. I got two answers to my problem and they both work
great. Thanks again!!!
"Ulrik Skovenborg" <"skovenborg at frac dot dk"> wrote in message
news:41***********************@news.sunsite.dk...
P Wolpert wrote:
From what I know, and
that's not much, I need to put both scripts in the "Onload" command. I
just
don't know how to write the script for the scrolling text because it
doesn't
use the "Onload" command.


You can run several functions from the onload-event by seperating them
with semi-colon:
<body onload="initMenus();startscroll();">

After that you can remove this line:
window.onload=startscroll
from the scroll-script.

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tony Strazzeri | last post by:
Hi all, I a fairly new to html and Javascripting. I have been trying to write some code to hide my email address from spam harvesters. I copied the code from various web examples and modified...
3
by: Shapper | last post by:
Hello, Until now I have been using Dreamweaver to create ASP.Net/VB web sites. I gave up of using it. Too many limitations. What is the best software to create ASP.NET/VB web sites? Maybe...
4
by: Brie_Manakul | last post by:
I need to set up an if else to show different weather scripts based on the city selection they choose. Any help on this would be great. Thanks! <%@ page language="java" import="java.util.*,...
2
by: ranger7419 | last post by:
I'm trying to figure out why this script will work in IE 6 but not Firefox, and so I need someone here with a far better grasp on javascript to explain this. Basically, I have a page with several...
3
by: mike.biang | last post by:
I am using the XMLHTTP object to request a page from within another ASP page. For my scenario, the two pages should operate in the same session. However, when I request the second page, a new...
8
by: Milsnips | last post by:
hi there, i'm currently using the following line: <script language="javascript" type="text/javascript" src="../scripts/timer.js"></script> but i want to do the following, as the script...
5
eragon
by: eragon | last post by:
I am making a password script, i have most of it done, ill show you, but i hit a brick wall.... lol, I have it so when you log in it takes you to your main page, that works, but when you enter the...
4
by: Jonathan Wood | last post by:
I'm trying to duplicate an HTML sample I have using my ASP.NET pages. The sample contains the following within the <headtag: <script type="text/javascript" src="flashobject.js"></script>...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.