Click to See Complete Forum and Search --> : two scripts not working


bash
09-11-2003, 01:18 PM
I have incorporated two scripts on my sports car community home page but one works and the other does not?

The first script changes one image to another when the mouse is over each of the menu buttons on the left.

The second script is a news ticker which works.

Below is the code for the homepage, second post has the first script then the third post has the second script.

-----------------homepage-----------------------
<html>

<head>

<title>Car Community Call</title>

<style fprolloverstyle>
A:hover {color: #000000;}
A:link {color:#FFFFFF;}
</style>

<script type="text/javascript">

function init() {
if (!document.getElementById) return
var imgOriginSrc;
var imgTemp = new Array();
var imgarr = document.getElementsByTagName('img');
for (var i = 0; i < imgarr.length; i++) {
if (imgarr[i].getAttribute('hsrc')) {
imgTemp[i] = new Image();
imgTemp[i].src = imgarr[i].getAttribute('hsrc');
imgarr[i].onmouseover = function() {
imgOriginSrc = this.getAttribute('src');
this.setAttribute('src',this.getAttribute('hsrc'))
}
imgarr[i].onmouseout = function() {
this.setAttribute('src',imgOriginSrc)
}
}
}
}
onload=init

</script>

</head>

<body bgcolor="#cccccc" link="#D0BCB9" vlink="#FFFFFF" alink="#FFFFFF" text="#FFFFFF">

<div align="center">
<center>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#000000" width="772" background="front5.jpg">
<tr>
<td width="770" background="bar5.jpg" colspan="2" valign="top">
<p style="margin-top: 0; margin-bottom: 0">&nbsp;</p>
<p style="margin-top: 0; margin-bottom: 0"><font face="Tahoma"><b>&nbsp;<font color="#FFFFFF"></font></b></font></p>
<p style="margin-top: 0; margin-bottom: 0">&nbsp;</td>
</tr>
<tr>
<td width="770" colspan="2" valign="top" bgcolor="#000000">
<p style="margin-top: 0; margin-bottom: 0">
&nbsp&nbsp&nbsp&nbsp</td>
</tr>
<tr>
<td width="190" valign="top">
<p style="margin-top: 0; margin-bottom: 0">&nbsp;</p>
<p align="center" style="margin-top: 0; margin-bottom: 0">
<a href="aboutus.htm">
<img border="1" src="one.gif" width="156" height="26" hsrc="onecopy.jpg"></p>
</a>
<p align="center" style="margin-top: 0; margin-bottom: 0">&nbsp;</p>
<p align="center" style="margin-top: 0; margin-bottom: 0">
<a href="carservices.htm">
<img border="1" src="two.gif" width="156" height="26" hsrc="twocopy.jpg"></p>
</a>
<p align="center" style="margin-top: 0; margin-bottom: 0">&nbsp;</p>
<p align="center" style="margin-top: 0; margin-bottom: 0">
<a href="specialoccasions.htm">
<img border="1" src="three.gif" width="156" height="26" hsrc="threecopy.jpg"></p>
</a>
<p align="center" style="margin-top: 0; margin-bottom: 0">&nbsp;</p>
<p align="center" style="margin-top: 0; margin-bottom: 0">
<a href="oldfleet.htm">
<img border="1" src="four.gif" width="156" height="26" hsrc="sixcopy.jpg"></p>
</a>
<p align="center" style="margin-top: 0; margin-bottom: 0">&nbsp;</p>
<p align="center" style="margin-top: 0; margin-bottom: 0">
<a href="contactus.htm">
<img border="1" src="five.gif" width="156" height="26" hsrc="fivecopy.jpg"></p>
</a>
<p align="center" style="margin-top: 0; margin-bottom: 0">&nbsp;</p>
<p align="center" style="margin-top: 0; margin-bottom: 0">
<a href="faq.htm">
<img border="1" src="six.gif" width="156" height="26" hsrc="sevencopy.jpg"></p>
</a>


<p style="margin-top: 0; margin-bottom: 0">&nbsp;</td>
<td width="579" valign="top">&nbsp;<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="97%" bordercolor="#000000">
<tr>
<td width="100%">




<br><br>

<center>
<div style="position:relative;width:525; height:22;overflow:hidden; margin:0px;"><div id="spage" style="position:relative; width:1000; height:22;

background: #EEEEEE; overflow:hidden; FILTER:

progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=0.20,wipestyle=0,motion=forward,duration =1);"></div><script language="javascript"

src="headline.js"></script></div>
</center>

</tr>
</table>
</center>
</div>
</td>
</tr>
</table>

<center>
<font face="Arial, Helvetica, sans-serif" size="1" color="000000"><b>&copy;
Copyright 2003. Car Care. <a href="terms.htm">Terms & Conditions</a>&nbsp&nbsp
</b></font>
</center>
</div>

</body>

</html>

-----------------end homepage-----------------------

see "two scripts not working part two"

bash
09-11-2003, 01:19 PM
Here is the first script..


-----------------first script--------------------------

var theight=22; var transtime=1000; borderw=1; var pad_top=4; var pad_top2=4; var pad_left=8; var pad_left2=0; borderd='border-style:solid; border-width:1px; border-color:#000000;'; var text_alignt='left'; var text_alignh='center'; var text_decort='none'; var text_decorh='none'; var fstylet='normal'; var fstyleh='normal'; var fweightt='normal'; var fweighth='bold'; var fontn='Verdana'; bgcol = '#EEEEEE'; bgcolh = '#990000'; txtcol = '#060606'; txthicol = '#B40000'; txtcolh = '#E9E9E9'; border_color_str='#000000'; var nstheight=0,nst2width=0;

var text = new Array();
text[0] = "The red car.";
text[1] = "The green car.";
text[2] = "The blue car.";
var header = new Array();header[0] = "Red";header[1] = "Green";header[2] = "Blue";
var linka = new Array();linka[0] = "partners.htm";linka[1] = "partners.htm";linka[2] = "partners.htm";
var targa = new Array();targa[0] = "_self";targa[1] = "_self";targa[2] = "_self";
var divtext = new Array(); var divh = new Array(); var objst = new Array(); var objs = new Array(); var objsh = new Array();
var IE4B=false;var NS4B=false;var NS6B=false;var OP5B=false; NS4B=((document.layers)?true:false); IE4B=((document.all)?true:false); NS6B=((document.getElementById)&&(!IE4B))?true:false; uagent = window.navigator.userAgent.toLowerCase();IE5=false;IE4=false;IEold=false;IE5=(uagent.indexOf('msie 5.0') != -1)?true:false;IE4=(uagent.indexOf('msie 4') != -1)?true:false;if(IE5||IE4){IEold=true;} OP5B=(uagent.indexOf('opera') != -1)?true:false; if(OP5B==true){IE4B=false;NS6B=true;} if(NS6B==true){IE4B=false;}
var ns6obj=null; var str2=''; var msgw,msgh; var mc=0; var say=0,onceki=0; msgw=500-120; mc=text.length; onceki=mc-1; strpos='';strvis='';strpadding='',strpadding2='';nsdiv=''; nstheight=theight-borderw-borderw; nst2width=500-borderw-borderw; pad_top=pad_top-borderw; if(pad_top<0){pad_top=0;} pad_top2=pad_top2-borderw; if(pad_top2<0){pad_top2=0;}
if(IE4B){ strpos='position:absolute;'; strvis=''; strpadding='padding-top:'+pad_top+'px;padding-left:'+pad_left+'px;'; strpadding2='padding-top:'+pad_top2+'px;padding-left:'+pad_left2+'px;';}else if(NS6B){ strpos='position:absolute;'; strvis='visibility:hidden;'; strpadding='padding-top:'+pad_top+'px;padding-left:'+pad_left+'px;'; strpadding2='padding-top:'+pad_top2+'px;padding-left:'+pad_left2+'px;';}
divtev1=' onmouseover="mdivmo('; divtev2=')" onmouseout ="restime('; divtev3=')" onclick="butclick('; divtev4=')"';
for(i=0;i<mc;i++) { if(IE4B) { divtext[i]='<div id=d'+i+' onmouseover="mdivmo('+i+')" onmouseout ="restime('+i+')" onclick="butclick('+i+')"'+' style="'+strpos+''+strvis+'background:'+bgcol+'; COLOR: '+txtcol+'; '+strpadding+' left:'+120+'; top:0; width:1600 ;height:'+theight+'; FONT-FAMILY: '+fontn+'; FONT-SIZE: '+8+'pt; font-style: '+fstylet+'; font-weight: '+fweightt+'; margin:0px; TEXT-DECORATION: '+text_decort+'; overflow-y:hidden;text-align:'+text_alignt+';cursor: default;">'; divh[i]='<div id=dh'+i+' style="'+strpos+''+strvis+'background:'+bgcolh+'; COLOR: '+txtcolh+'; '+strpadding2+' left:0; top:0; width:'+120+'; height:'+theight+'; FONT-FAMILY: '+fontn+'; FONT-SIZE: '+9+'pt; font-style: '+fstyleh+'; font-weight: '+fweighth+'; TEXT-DECORATION: '+text_decorh+';margin:0px; overflow:hidden;;text-align:'+text_alignh+';cursor: default;">'; } else if(NS6B) { divtext[i]='<div id=d'+i+' onmouseover="mdivmo('+i+')" onmouseout ="restime('+i+')" onclick="butclick('+i+')"'+' style="'+strpos+''+strvis+'background:'+bgcol+'; COLOR: '+txtcol+'; '+strpadding+' left:'+120+'; top:0; width:1600 ;height:'+nstheight+'; FONT-FAMILY: '+fontn+'; FONT-SIZE: '+8+'pt; font-style: '+fstylet+'; font-weight: '+fweightt+'; TEXT-DECORATION: '+text_decort+';margin:0px; overflow-y:hidden;text-align:'+text_alignt+';cursor: default;">'; divh[i]='<div id=dh'+i+' style="'+strpos+''+strvis+'background:'+bgcolh+'; COLOR: '+txtcolh+'; '+strpadding2+' left:0; top:0; width:'+120+'; height:'+nstheight+'; FONT-FAMILY: '+fontn+'; FONT-SIZE: '+9+'pt; font-style: '+fstyleh+'; font-weight: '+fweighth+'; TEXT-DECORATION: '+text_decorh+';margin:0px;overflow:hidden;text-align:'+text_alignh+';cursor: default;">'; } }
function mdivmo(gnum) { if(IE4B) { if(linka[gnum]!='') { objd=eval('d'+gnum); objd.style.color=txthicol; objd.style.cursor='hand'; window.status=''+linka[gnum]; } } else if(NS6B) { if(linka[gnum]!='') { objs[onceki].style.color=txthicol; objs[onceki].style.cursor='pointer'; window.status=''+linka[gnum]; } }}function restime(gnum2){ if(IE4B) { objd=eval('d'+gnum2); objd.style.color=txtcol; window.status=''; } else if(NS6B) { objs[onceki].style.color=txtcol; window.status=''; }}function butclick(gnum3){ if(targa[gnum3]==''){targa[gnum3]='_self';} if(IE4B) { window.open(''+linka[gnum3],''+targa[gnum3]); } else if(NS6B) { window.open(''+linka[gnum3],''+targa[gnum3]); }}
if(IE4B){} else if(NS6B){ str2=''; for(i=0;i<mc;i++) { str2=str2+'<div id=op'+i+' style="position:absolute;overflow:hidden;'+strvis+' left:0;top:0;width:'+nst2width+'; height:'+nstheight+';'+strvis+borderd+'">'; str2=str2+''+divh[i]+header[i]+'</div>'+divtext[i]+''+text[i]+'</div>'; str2=str2+'</div>'; }} else if(NS4B){}
function dotrans(){ if(IE4B) { spage.innerHTML =''+divh[say]+'</div>'+divtext[say]+'</div>'; if(IEold!=true){spage.filters[0].apply();} spage.innerHTML =''+divh[say]+header[say]+'</div>'+divtext[say]+text[say]+'</div>'; if(IEold!=true){spage.filters[0].play();} setTimeout('dotrans()',3000+transtime); } else if(NS6B) { objsh[say].style.visibility='visible'; objsh[onceki].style.visibility='hidden'; objs[say].style.color=txtcol; objs[say].style.visibility='visible'; objs[onceki].style.visibility='hidden'; objst[say].style.visibility='visible'; objst[onceki].style.visibility='hidden'; onceki=say; setTimeout('dotrans()',3000); } say++; if(say>=mc){say=0;}}
function dofirst() { var i=0; var str=""; for(i=0;i<mc;i++) { str="d"+i; objs[i]=document.getElementById(str); objs[i].style.left=""+120+"px"; objs[i].style.top="0px"; objs[i].style.visibility="hidden"; str="dh"+i; objsh[i]=document.getElementById(str); objsh[i].style.left="0px"; objsh[i].style.top="0px"; objsh[i].style.visibility="hidden"; str="op"+i; objst[i]=document.getElementById(str); objst[i].style.left="0px"; objst[i].style.top="0px"; objst[i].style.visibility="hidden"; } objs[0].style.visibility="visible"; objsh[0].style.visibility="visible"; objst[0].style.visibility="visible"; dotrans(); }
function initte() { if(IE4B) { spage.style.borderStyle="solid"; spage.style.borderWidth=""+borderw+"px"; spage.style.borderColor=border_color_str; spage.innerHTML=""+divh[say]+header[say]+"</div>"+divtext[0]+text[0]+"</div>"; say=1; setTimeout('dotrans()',3000); } else if(NS6B) { say=0; ns6obj=document.getElementById('spage'); ns6obj.innerHTML=str2; setTimeout('dofirst()',500); } }window.onload=initte;


-----------------end first script--------------------------

see "two scripts not working part three"

bash
09-11-2003, 01:22 PM
-----------------second script-----------------------------

/* USE WORDWRAP AND MAXIMIZE THE WINDOW TO SEE THIS FILE
========================================
V-NewsTicker v2.1
License : Freeware (Enjoy it!)
(c)2003 VASIL DINKOV- PLOVDIV, BULGARIA
========================================
For IE4+, NS4+ & Opera5+
========================================
Get the NewsTicker script at:
http://www.smartmenus.org/other.php
and don't wait to get the Great SmartMenus script at:
http://www.smartmenus.org
LEAVE THESE NOTES PLEASE - delete the comments if you want */

// BUG in Opera:
// If you want to be able to control the body margins
// put the script right after the BODY tag, not in the HEAD!!!

// === 1 === FONT, COLORS, EXTRAS...
v_font='verdana,arial,sans-serif';
v_fontSize='10px';
v_fontSizeNS4='11px';
v_fontWeight='bold';
v_fontColor='#ffffff';
v_textDecoration='none';
v_fontColorHover='#ffffff';// | won't work
v_textDecorationHover='underline';// | in Netscape4
v_bgColor='url(bg.jpg)';
// set [='transparent'] for transparent
// set [='url(image_source)'] for image
v_top=0;// |
v_left=0;// | defining
v_width=200;// | the box
v_height=52;// |
v_paddingTop=2;
v_paddingLeft=2;
v_position='relative';//absolute or relative
v_timeout=2500;//1000 = 1 second
v_slideSpeed=30;
v_slideDirection=0;//0=down-up;1=up-down
v_pauseOnMouseOver=true;

// === 2 === THE CONTENT - ['href','text','target']
// Use '' for href to have no link item
v_content=[
['partners.htm','<img src=strelka.gif align=top width=20 height=11 border=0>beauford<br>beauford vintage is cool.details.','_blank'],
['partners.htm','<img src=strelka.gif align=top width=20 height=11 border=0>CARS<br>Best in Classic and Vintage Wedding Vehicles. Click for further details.','_blank'],
['partners.htm','<img src=strelka.gif align=top width=20 height=11 border=0>freds<br>Cars - Ferrari for sport, Bentley for prestige and Beauford for vintage.','_blank']
];

// THE SERIOUS SCRIPT - PLEASE DO NOT TOUCH
v_ua=navigator.userAgent;v_nS4=document.layers?1:0;v_iE=document.all&&!window.innerWidth&&v_ua.indexOf("MSIE")!=-1?1:0;v_oP=v_ua.indexOf("Opera")!=-1&&document.clear?1:0;v_oP4=v_ua.indexOf("Opera")!=-1&&!document.clear;v_kN=v_ua.indexOf("Konqueror")!=-1&&parseFloat(v_ua.substring(v_ua.indexOf("Konqueror/")+10))<3.1?1:0;v_count=v_content.length;v_s1=1;v_cur=1;v_cl=0;v_d=v_slideDirection?-1:1;v_TIM=0;v_fontSize2=v_nS4&&navigator.platform.toLowerCase().indexOf("win")!=-1?v_fontSizeNS4:v_fontSize;v_canPause=0;function v_getOS(a){return v_iE?document.all[a].style:v_nS4?document.layers['v_container'].document.layers[a]:document.getElementById(a).style};function v_start(){var o=v_getOS('v_1');var px=v_nS4?0:'px';if(v_iE||v_oP){if(o.pixelTop==v_paddingTop){v_canPause=1;if(v_count>1)v_TIM=setTimeout("v_canPause=0;v_slide()",v_timeout);return};o.pixelTop-=v_d;if(v_oP&&o.visibility.toLowerCase()!='visible')o.visibility='visible';setTimeout("v_start()",v_slideSpeed);return};if(parseInt(o.top)==v_paddingTop){v_canPause=1;if(v_count>1)v_TIM=setTimeout("v_canPause=0;v_slide()",v_timeout);return};o.top=parseInt(o.top)-v_d+px;setTimeout("v_start()",v_slideSpeed)};function v_slide(){var o=v_getOS('v_'+v_cur);var o2=v_getOS('v_'+(v_cur<v_count?v_cur+1:1));var px=v_nS4?0:'px';if(v_iE||v_oP){if(o.pixelTop==v_paddingTop*2-v_height*v_d){if(v_oP)o.visibility='hidden';o.pixelTop=v_height*v_d;v_cur=v_cur<v_count?v_cur+1:1;v_canPause=1;v_TIM=setTimeout("v_canPause=0;v_slide()",v_timeout);return};o.pixelTop-=v_d;if(v_oP&&o2.visibility.toLowerCase()!='visible')o2.visibility='visible';o2.pixelTop-=v_d;setTimeout("v_slide()",v_slideSpeed);return};if(parseInt(o.top)==v_paddingTop*2-v_height*v_d){o.top=v_height*v_d+px;v_cur=v_cur<v_count?v_cur+1:1;v_canPause=1;v_TIM=setTimeout("v_canPause=0;v_slide()",v_timeout);return};o.top=parseInt(o.top)-v_d+px;o2.top=parseInt(o2.top)-v_d+px;setTimeout("v_slide()",v_slideSpeed)};if(v_nS4||v_iE||v_oP||document.getElementById&&!v_kN&&!v_oP4){document.write('<style>.vnewsticker,a.vnewsticker{font-family:'+v_font+';font-size:'+v_fontSize2+';color:'+v_fontColor+';text-decoration:'+v_textDecoration+';font-weight:'+v_fontWeight+'}a.vnewsticker:hover{font-family:'+v_font+';font-size:'+v_fontSize2+';color:'+v_fontColorHover+';text-decoration:'+v_textDecorationHover+'}</style>');v_temp='<div '+(v_nS4?"name":"id")+'=v_container style="position:'+v_position+';top:'+v_top+'px;left:'+v_left+'px;width:'+v_width+'px;height:'+v_height+'px; background:'+v_bgColor+';layer-background'+(v_bgColor.indexOf("url(")==0?"-image":"-color")+':'+v_bgColor+';clip:rect(0,'+v_width+','+v_height+',0);overflow:hidden">';for(v_i=0;v_i<v_count;v_i++)v_temp+='<div '+(v_nS4?"name":"id")+'=v_'+(v_i+1)+' style="position:absolute;top:'+(v_height*v_d)+'px;left:'+v_paddingLeft+'px;width:'+(v_width-v_paddingLeft*2)+'px;height:'+(v_height-v_paddingTop*2)+'px;clip:rect(0,'+(v_width-v_paddingLeft*2)+','+(v_height-v_paddingTop*2)+',0);overflow:hidden'+(v_oP?";visibility:hidden":"")+'" class=vnewsticker>'+(v_content[v_i][0]!=''?'<a href="'+v_content[v_i][0]+'" target="'+v_content[v_i][2]+'" class=vnewsticker'+(v_pauseOnMouseOver?" onmouseover=\'if(v_canPause&&v_count>1){clearTimeout(v_TIM);v_cl=1}\' onmouseout=\'if(v_canPause&&v_count>1&&v_cl)v_TIM=setTimeout(\"v_canPause=0;v_slide();v_cl=0\","+v_timeout+")\'":"")+'>':'<span'+(v_pauseOnMouseOver?" onmouseover=\'if(v_canPause&&v_count>1){clearTimeout(v_TIM);v_cl=1}\' onmouseout=\'if(v_canPause&&v_count>1&&v_cl)v_TIM=setTimeout(\"v_canPause=0;v_slide();v_cl=0\","+v_timeout+")\'":"")+'>')+v_content[v_i][1]+(v_content[v_i][0]!=''?'</a>':'</span>')+'</div>';v_temp+='</div>';document.write(v_temp);setTimeout("v_start()",1000);if(v_nS4)onresize=function(){location.reload()}}

-----------------end second script-----------------------------

i hope someone can help me get both scripts working in tandem.

Thank you.

requestcode
09-11-2003, 01:42 PM
Instead of creating three different post you can add to one post by clicking on the edit button in the lower right corner. Your three post make it difficult if not impossible to help. They also tend to annoy people and will cause them not to help.

pyro
09-11-2003, 03:19 PM
As requestcode stated, please do not start multiple threads on the same topic, as it makes it very hard for anyone to help you. I've merged them all together.

pyro
09-11-2003, 03:22 PM
One thing that is going to be problematic is your two onload calls in the javascript. This (http://forums.webdeveloper.com/showthread.php?s=&threadid=17262) thread should help you.

bash
09-12-2003, 05:37 AM
Sorry for posting three posts for one problem.

Didn't know how to merge them. DO now though!!!

I am learning Javascript at the moment and really haven't got the grasp on how to amend the scripts so they work in tandem.

Please can you show me what code needs changing as i have tried to follow the very simple solution but me being me, i just do not know how to.

Again sorry for using up posting space and also being rather dim ;-)

Thanks again, Pyro....