...

View Full Version : Cant use same script twice in firefox



copynpaster
05-04-2006, 05:51 PM
alright guys, this is gonna be a hard one for you all, or maybe not.
I want to use one same javascript (text up-down scroller) twice on the same page (which is my homepage). So, what i'm doing right now is that i'm calling to functions populate() and populate2() in the body tag of my index file.
hence my body tag looks like <body onload= populate(); populate2();>
My two javascripts reside
in two external .js files, named hindimoviesscript.js and othermoviesscript.js.
I'm calling the two javascripts at two different locations like this:
<td><script src="hindimoviescript.js"></script></td>
<td><script src="othermoviescript.js"></script></td>

Now the problem is that both the scripts work fine in IE, but in firefox, only the first one loads up and not the second one...
to visualise the problem go to www.bombaybazaarmadison.com in IE and then in firefox...
i have already changed the name of the variables and other functions in the second script...
here's my first .js file ( hindimoviesscripts.js):
****************************************************


// Scrollers width here (in pixels)
var scrollerwidth="120px"

// Scrollers height here
var scrollerheight="200px"

// Scrollers speed here (larger is faster 1-10)
var scrollerspeed=1

// Scrollers content goes here! Keep all of the message on the same line!

var scrollercontent='<center><font face="verdana" size="2" color="005680"><b>Benaras<br>Naughty Boy<br>Being Cyrus<br>Malaamal Weekly<br>Umar<br>Taxi No 9211 <br>Banana Brothers<br>Teesri Aankh<br>Madhubala<br>(Mr. 100% The Real Player)<br>Rang De Basanti<br>Holiday<br>Dosti<br>Fight Club<br>Zinda<br></b></font><center>'

var pauseit=2

// Change nothing below!

scrollerspeed=(document.all)? scrollerspeed : Math.max(1, scrollerspeed-1) //slow speed down by 1 for NS
var copyspeed=scrollerspeed
var iedom=document.all||document.getElementById
var actualheight=''
var cross_scroller, ns_scroller
var pausespeed=(pauseit==0)? copyspeed: 0

function populate(){
if (iedom){
cross_scroller=document.getElementById? document.getElementById("iescroller") : document.all.iescroller
cross_scroller.style.top=parseInt(scrollerheight)+8+"px"
cross_scroller.innerHTML=scrollercontent
actualheight=cross_scroller.offsetHeight
}
else if (document.layers){
ns_scroller=document.ns_scroller.document.ns_scroller2
ns_scroller.top=parseInt(scrollerheight)+8
ns_scroller.document.write(scrollercontent)
ns_scroller.document.close()
actualheight=ns_scroller.document.height
}
lefttime=setInterval("scrollscroller()",20)
}


function scrollscroller(){

if (iedom){
if (parseInt(cross_scroller.style.top)>(actualheight*(-1)+8))
cross_scroller.style.top=parseInt(cross_scroller.style.top)-copyspeed+"px"
else
cross_scroller.style.top=parseInt(scrollerheight)+8+"px"
}
else if (document.layers){
if (ns_scroller.top>(actualheight*(-1)+8))
ns_scroller.top-=copyspeed
else
ns_scroller.top=parseInt(scrollerheight)+8
}
}

if (iedom||document.layers){
with (document){
if (iedom){
write('<div style="position:relative;width:'+scrollerwidth+';height:'+scrollerheight+';overflow:hidden" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=scrollerspeed">')
write('<div id="iescroller" style="position:absolute;left:0px;top:0px;width:100%;">')
write('</div></div>')
}
else if (document.layers){
write('<ilayer width='+scrollerwidth+' height='+scrollerheight+' name="ns_scroller">')
write('<layer name="ns_scroller2" width='+scrollerwidth+' height='+scrollerheight+' left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=scrollerspeed"></layer>')
write('</ilayer>')
}
}
}

***********************************************************


Othermoviesscript.js:

************************************************

// Scrollers width here (in pixels)
var scrollerwidth2="120px"

// Scrollers height here
var scrollerheight2="200px"

// Scrollers speed here (larger is faster 1-10)
var scrollerspeed2=1

// Scrollers content goes here! Keep all of the message on the same line!

var scrollercontent2='<center><font face="verdana" size="2" color="005680"><b><font size="2" color ="#FF9933">Telugu</font><br>---------------<br>Yuvakulu<br>Athadu<br>Ayyinda Leda<br>Ji<br>Mogudspellams<br>Seenugadu<br>Police<br>Ghajini<br>Sarada Saradaga<br>Nayakudu<br>Keedi No1<br>Ghambeera<br>Bommoa Ammo<br>SMS<br>Charrpathi<br>-------------<br><br><font size="2" color="#FF9933">Tamil</font><br>-------------<br>Sukran<br>Thottachinunga<br>Veeran<br>Sevvel<br>-------------<br><br><font size="2" color="#FF9933">Punjabi</font><br>-------------<br>Pind Di Kudi<br>Kesari Nishaan Jhoolde<br>(Siddha Chal Canada Nu)<br>-------------<br><br><font size="2" color="#FF9933">Malyalam</font><br>-------------<br>Koottu<br>Chiuna<br>-------------</b></font><center>'

var pauseit2=2

// Change nothing below!

scrollerspeed2=(document.all)? scrollerspeed2 : Math.max(1, scrollerspeed2-1) //slow speed down by 1 for NS
var copyspeed2=scrollerspeed2
var iedom2=document.all||document.getElementById2
var actualheight2=''
var cross_scroller2, ns_scroller2
var pausespeed2=(pauseit2==0)? copyspeed2: 0

function populate2(){
if (iedom2){
cross_scroller2=document.getElementById2? document.getElementById("iescroller") : document.all.iescroller2
cross_scroller2.style.top=parseInt(scrollerheight2)+8+"px"
cross_scroller2.innerHTML=scrollercontent2
actualheight2=cross_scroller2.offsetHeight
}
else if (document.layers){
ns_scroller2=document.ns_scroller2.document.ns_scroller3
ns_scroller2.top=parseInt(scrollerheight2)+8
ns_scroller2.document.write(scrollercontent2)
ns_scroller2.document.close()
actualheight2=ns_scroller2.document.height
}
lefttime2=setInterval("scrollscroller2()",20)
}


function scrollscroller2(){

if (iedom2){
if (parseInt(cross_scroller2.style.top)>(actualheight2*(-1)+8))
cross_scroller2.style.top=parseInt(cross_scroller2.style.top)-copyspeed2+"px"
else
cross_scroller2.style.top=parseInt(scrollerheight2)+8+"px"
}
else if (document.layers){
if (ns_scroller2.top>(actualheight2*(-1)+8))
ns_scroller2.top-=copyspeed2
else
ns_scroller2.top=parseInt(scrollerheight2)+8
}
}

if (iedom2||document.layers){
with (document){
if (iedom2){
write('<div style="position:relative;width:'+scrollerwidth2+';height:'+scrollerheight2+';overflow:hidden" onMouseover="copyspeed2=pausespeed2" onMouseout="copyspeed2=scrollerspeed2">')
write('<div id="iescroller2" style="position:absolute;left:0px;top:0px;width:100%;">')
write('</div></div>')
}
else if (document.layers){
write('<ilayer width='+scrollerwidth2+' height='+scrollerheight2+' name="ns_scroller2">')
write('<layer name="ns_scroller2" width='+scrollerwidth2+' height='+scrollerheight2+' left=0 top=0 onMouseover="copyspeed2=pausespeed2" onMouseout="copyspeed2=scrollerspeed2"></layer>')
write('</ilayer>')
}
}


********************************************************************************

FYI, this is one of dynamicdrivescripts.....
once again, it works in IE, but only 1 script works in firefox...

Please help....

Beagle
05-04-2006, 05:56 PM
<body onload="populate(); populate2();">

Try putting quotes around the onload attribute as above.

All attributes must have quotes around them according to the HTML and XHTML standards.

copynpaster
05-04-2006, 06:20 PM
i'm sorry, i already have those quotes.....
just mistyped it in the thread.

Beagle
05-04-2006, 06:23 PM
try this:

function mainPopulate()
{
populate1();
populate2();
}

<body onload="mainPopulate();">

copynpaster
05-04-2006, 06:33 PM
beagle,

where do i declare the mainPopulate function?

Beagle
05-04-2006, 06:39 PM
in a script block after you include the other scripts:

<script type="text/javascript" src="orly"></script>
<script type="text/javascript" src="yarly"></script>
<script type="text/javascript">
function noWai()
{
populate1();
populate2();
}
</script>

<body onload="noWai();">

copynpaster
05-04-2006, 06:59 PM
tried that, didnt work....
still works in IE..but firefox only shows 1 script !!

Beagle
05-04-2006, 07:08 PM
well, I was using populate1() which should be populate(), I'm assuming you caught that.

Other than that, you're going to have to throw some alerts into populate and populate2 and figure out what's going on.

Can't do much more than that without testing it for you.

copynpaster
05-04-2006, 07:14 PM
yeah I indeed caught that....
dont know what else to try.

Beagle
05-04-2006, 07:24 PM
put alerts inside populate and populate2 and see if they're executing at all?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum