PDA

View Full Version : Simple Java Code Problem


MaR?
04-12-2009, 03:40 AM
This Java Code have this error:

else {document.write('<img src='XXXXXXXXXXXXXXXXXXXX/+seleccionado+' width='+width+' height='+height+'>');


It suppose to be:

else {document.write('<img src='XXXXXXXXXXXXXXXXXXXX/'+seleccionado+' width='+width+' height='+height+'>');

But I dont know where to make the change on the code:


<script type="text/javascript">;
<!--
width="900"; //Anchura del banner
height="140"; //Altura del banner

banners= new Array();
banners[0]="XXXXXXXXXX/images/misc/cabe0.jpg";
banners[1]="XXXXXXXXXX/images/misc/cabe1.jpg";
banners[2]="XXXXXXXXXX/images/misc/cabe2.jpg";
banners[3]="XXXXXXXXXX/images/misc/cabe3.jpg";
banners[4]="XXXXXXXXXX/images/misc/cabe4.jpg";
banners[5]="XXXXXXXXXX/images/misc/cabe5.jpg";
banners[6]="XXXXXXXXXX/images/misc/cabe6.jpg";
banners[7]="XXXXXXXXXX/images/misc/cabe7.jpg";
banners[8]="XXXXXXXXXX/images/misc/cabe8.jpg";
banners[9]="XXXXXXXXXX/images/misc/cabe9.jpg";
banners[10]="XXXXXXXXXX/images/misc/cabe10.jpg";
banners[11]="XXXXXXXXXX/images/misc/cabe11.jpg";
banners[12]="XXXXXXXXXX/images/misc/cabe12.jpg";
banners[13]="XXXXXXXXXX/images/misc/cabe13.jpg";
banners[15]="XXXXXXXXXX/images/misc/cabe14.jpg";
banners[14]="XXXXXXXXXX/images/misc/cabe16.jpg";
banners[16]="XXXXXXXXXX/images/misc/cabe17.jpg";
banners[17]="XXXXXXXXXX/images/misc/cabe18.jpg";
banners[18]="XXXXXXXXXX/images/misc/cabe19.jpg";
banners[19]="XXXXXXXXXX/images/misc/cabe20.jpg";
banners[20]="XXXXXXXXXX/images/misc/cabe21.jpg";
banners[21]="XXXXXXXXXX/images/misc/cabe22.jpg";
banners[22]="XXXXXXXXXX/images/misc/cabe23.jpg";
banners[23]="XXXXXXXXXX/images/misc/cabe24.jpg";
banners[24]="XXXXXXXXXX/images/misc/cabe25.jpg";
banners[25]="XXXXXXXXXX/images/misc/cabe26.jpg";
banners[26]="XXXXXXXXXX/images/misc/cabe27.jpg";
banners[27]="XXXXXXXXXX/images/misc/cabe28.jpg";
banners[28]="XXXXXXXXXX/images/misc/cabe29.jpg";
banners[29]="XXXXXXXXXX/images/misc/cabe30.jpg";
banners[30]="XXXXXXXXXX/images/misc/cabe31.jpg";
banners[31]="XXXXXXXXXX/images/misc/cabe32.jpg";
banners[32]="XXXXXXXXXX/images/misc/cabe33.jpg";
banners[33]="XXXXXXXXXX/images/misc/cabe34.jpg";
banners[34]="XXXXXXXXXX/images/misc/cabe35.jpg";
banners[35]="XXXXXXXXXX/images/misc/cabe36.jpg";
banners[36]="XXXXXXXXXX/images/misc/cabe37.jpg";
banners[37]="XXXXXXXXXX/images/misc/cabe38.jpg";
banners[38]="XXXXXXXXXX/images/misc/cabe39.jpg";
banners[39]="XXXXXXXXXX/images/misc/cabe40.jpg";
banners[40]="XXXXXXXXXX/images/misc/cabe41.jpg";
banners[41]="XXXXXXXXXX/images/misc/cabe42.jpg";
banners[42]="XXXXXXXXXX/images/misc/cabe43.jpg";


totalbanners = banners.length;
var ahora = new Date()
var segundos = ahora.getSeconds()
var ad = segundos % totalbanners;
seleccionado=banners[ad];
localizador=seleccionado.lastIndexOf('.');
localizador2=localizador+4
extension=seleccionado.substring(localizador+1,loc alizador2);
archivo=seleccionado.substring(0,localizador);

document.write("<center>");
if (extension=="swf"){
flash=seleccionado;
document.write('<OBJECT CLASSID=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=' + width + ' height=' + height + ' CODEBASE=\"xxxxxxxxxxxxxxx/flash4/cabs/swflash.cab#version=4,0,0,0\">');
document.write('<PARAM NAME=\"MOVIE\" VALUE=\"' + flash + '\">');
document.write('<PARAM NAME=\"PLAY\" VALUE=\"true\">');
document.write('<PARAM NAME=\"LOOP\" VALUE=\"true\">');
document.write('<PARAM NAME=\"QUALITY\" VALUE=\"high\">');
document.write('<EMBED SRC=' + flash + ' width=' + width + ' height=' + height + ' PLAY=\"true\" LOOP=\"true\" QUALITY=\"high\" PLUGINSPAGE=\"xxxxxxxxxxxxxxxxxxx/shockwave/download/index.cgi? P1_Prod_Version=ShockwaveFlash\">');
document.write('</EMBED>');
document.write('</OBJECT>');}
else {document.write('<img src='+seleccionado+' width='+width+' height='+height+'>');
document.write('</center>');}
// -->;
</script>


I hope you can helpme!


Thanks

Dismounted
04-12-2009, 04:08 AM
Looks a lot like this line, doesn't it? ;)
else {document.write('<img src='+seleccionado+' width='+width+' height='+height+'>');

MaR?
04-12-2009, 04:24 AM
Totally!!!... but... donĀ“t you see the code line seems to be right... but after all I, having this error...

Im not a magic girl... I swear

I fell so stupid... I found this code on the internet... but Vbseo make the logos dissapear.... and they tellme there is the problem... but I cant fix It....

Lynne
04-12-2009, 03:41 PM
It's these lines which adds the image path to the word:

seleccionado=banners[ad];
localizador=seleccionado.lastIndexOf('.');
localizador2=localizador+4

I don't do javascript (java is very different from javascript which is what this is), so I'm not sure exactly what you should do. Play with it on your test site until it is right. (Is that last line missing a ; at the end?)