By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,179 Members | 2,192 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,179 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.