Uncaught TypeError: Failed to execute

Veronica Auretta

Nuovo Utente
21 Apr 2015
25
0
0
Ho un problema con questo script che ho trovato in rete... il problema è che funziona con firefox, ma non con gli altri browser. Premettendo che conosco poco e niente del linguaggio... penso che lo script sia molto vecchio, è possibile far qualcosa per renderlo funzionante o va cestinato e fatto d'accapo?

PHP:
<SCRIPT language=javascript>
	var obj1;
	var obj2;
	var obj3;
	var obj4;
	var obj5;
	var obj6;
	var blnFinish;
	var strBid='';

	function animate()
	{
		if(strBid=='')
		{
			alert('Bid on one handsome man!!');
			return false;
		}

		document.all['btnGO'].disabled=true;
		document.all['btnStart'].disabled=true;

		obj1=document.all['I1'];
		obj2=document.all['I2'];
		obj3=document.all['I3'];
		obj4=document.all['I4'];
		obj5=document.all['I5'];
		obj6=document.all['I6'];

		blnFinish=false;

		setTimeout("move(obj1)",100);
		setTimeout("move(obj2)",100);
		setTimeout("move(obj3)",100);
		setTimeout("move(obj4)",100);
		setTimeout("move(obj5)",100);
		setTimeout("move(obj6)",100);
	}

	function move(objX)
	{
		var strL;
		var strT;
		var strNext;
		var numRand;

		strL=objX.style.left;

		numRand=eval(generateRandom());
		objX.style.left=eval(strL.substring(0,strL.length-2))+numRand;

		strNext="move(document.all['" + objX.name + "'])";


		if((eval(strL.substring(0,strL.length-2)) < document.body.clientWidth-80) && blnFinish==false)
			setTimeout(strNext,30);
		else
		{
			blnFinish=true;
		}

		if((eval(strL.substring(0,strL.length-2)) >= document.body.clientWidth-80) && blnFinish==true)
		{
			objX.style.border="solid red 2px";
			document.all['btnStart'].disabled=false;


			if(objX == document.all['I' + strBid.substr(1)])
				alert('You Win!!');
			else
				alert('You Lose!!');
		}
	}

	function generateRandom()
	{
		var numRnd;

		numRnd=Math.random();

		if(numRnd<0.5)
		{
			return 1;
		}
		else
		{
			return 4;
		}
	}

	function animateWT()
	{
		setInterval("moveWT()",70);
	}

	function Restart()
	{
		document.all['I1'].style.left=0;
		document.all['I2'].style.left=0;
		document.all['I3'].style.left=0;
		document.all['I4'].style.left=0;
		document.all['I5'].style.left=0;
		document.all['I6'].style.left=0;

		document.all['I1'].style.border="solid 0px";
		document.all['I2'].style.border="solid 0px";
		document.all['I3'].style.border="solid 0px";
		document.all['I4'].style.border="solid 0px";
		document.all['I5'].style.border="solid 0px";
		document.all['I6'].style.border="solid 0px";

		document.all['C1'].className="start";
		document.all['C2'].className="start";
		document.all['C3'].className="start";
		document.all['C4'].className="start";
		document.all['C5'].className="start";
		document.all['C6'].className="start";
		strBid='';
		document.all['btnGO'].disabled=false;
	}

	function moveWT()
	{
		var strL;
		var strNext;

		strL=document.all['I1'].style.left;
		document.all['I1'].style.left=eval(strL.substring(0,strL.length-2))+2;

		strL=document.all['I2'].style.left;
		document.all['I2'].style.left=eval(strL.substring(0,strL.length-2))+2;

		strL=document.all['I3'].style.left;
		document.all['I3'].style.left=eval(strL.substring(0,strL.length-2))+2;

		strL=document.all['I4'].style.left;
		document.all['I4'].style.left=eval(strL.substring(0,strL.length-2))+2;

		strL=document.all['I5'].style.left;
		document.all['I5'].style.left=eval(strL.substring(0,strL.length-2))+2;

		strL=document.all['I6'].style.left;
		document.all['I6'].style.left=eval(strL.substring(0,strL.length-2))+2;

	}

	function changeClass(obj)
	{
		if(blnFinish!=false)
		{
			document.all['C1'].className="start";
			document.all['C2'].className="start";
			document.all['C3'].className="start";
			document.all['C4'].className="start";
			document.all['C5'].className="start";
			document.all['C6'].className="start";

			obj.className="start1";

			strBid=obj.id;
		}
	}

</SCRIPT>

Il problema che mi da è il seguente: Uncaught TypeError: Failed to execute 'animate' on 'Element': 1 argument required, but only 0 present
 

Discussioni simili