Jump to content
  • Advertisement
Sign in to follow this  
EkEk

[web] ie said invalid argument but firefox not saying anything

This topic is 4497 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi all, i'm trying to create somekind of progressbar. but something weird appear when i'm opening the page on ie, the code somehow doesn't work, and there's a page error, said there's "invalid argument". But when i open in firefox everything worked just fine. here is the full code. the error right now is on line 78. "bar.width = d;"
<html>
<head>
<title>testbar</title>

<script type="text/javascript">
var minutes = 0;
var seconds = 24;

var min = 0;
var sec = 0;

function InitTimer()
{
	min = minutes;
	sec = seconds;
}

function createTimeString()
{
	var str = document.getElementById( "timeString" );
	if( min > 0 || sec > 0)
	{
		if( sec > 0 )
			sec--;
		if( min > 0 && sec == 0 )
		{
			sec = 59;
			min--;
		}
		setTimeout( "createTimeString();", 1000 );
		var temp1 = minutes * 60 + seconds;
		var temp2 = min * 60 + sec;
		OnTimeInterval( temp1, temp2 );
	}
}


function OnTimeInterval( defaultTime, currentTime )
{
	var strTime = document.getElementById( 'timeString' );
	strTime.value = currentTime + '/' + defaultTime;
	var percentElapsed = ( ( defaultTime - currentTime ) / defaultTime ) * 100;
	SetCurrentPercent( 'ObjName', Math.floor( percentElapsed ) );
}

//	progress bar section
function InitProgressBar( id )
{
	var obj = document.getElementById( id );
	var box = document.getElementById( id + 'progressBox' );
	var bar = document.getElementById( id + 'progressBar' );
	var percentage = document.getElementById( id + 'Percentage' );
	box.width = obj.width - 10;
	var currentPercent = document.getElementById( id + 'CurrentPercent' );
	currentPercent.value = '0';
	SetCurrentPercent( id, 0 );
}
function SetCurrentPercent( id, percent )
{
	if( percent > 100 )
		percent = 100;
	else if(  percent < 0 )
		percent = 0;
	var box = document.getElementById( id + 'progressBox' );
	var bar = document.getElementById( id + 'progressBar' );
	var percentage = document.getElementById( id + 'Percentage' );
	var currentPercent = document.getElementById( id + 'CurrentPercent' );
	var showPercent = document.getElementById( id +
		'ShowPercent' ).value.toUpperCase() == 'true'.toUpperCase();

	if( showPercent )
	{
		percentage.innerHTML = percent + '/100';
	}
	else
	{
		percentage.innerHTML = '';
	}
	currentPercent.value = '' + percent;
	var a = box.width - 10;
	var b = percent / 100;
	var c = parseFloat( a ) * b;
	var d = parseInt( c );
//	alert( d );	<- the alert give a right value
	bar.width = d;   // <- THIS LINE CAUSE INVALID ARGUMENT IN IE, Arrrgghhh
//	bar.width = parseInt( parseFloat( (box.width - 10) ) * ( percent / 100 ) );

	if( percent == 0 )
	{
		bar.style.visibility = "hidden";
	}
	else
	{
		bar.style.visibility = "visible";
	}

}

function StepUp( id )
{
	var currentPercent = document.getElementById( id + 'CurrentPercent' );
	var valCurrentPercent = parseInt( currentPercent.value );
	var currentStepUp = document.getElementById( id + 'StepValue' );
	var currentStepUpValue = parseInt( currentStepUp.value );
	valCurrentPercent+= currentStepUpValue;
	SetCurrentPercent( id, valCurrentPercent );
}

function StepDown( id )
{
	var currentPercent = document.getElementById( id + 'CurrentPercent' );
	var valCurrentPercent = parseInt( currentPercent.value );
	var currentStepUp = document.getElementById( id + 'StepValue' );
	var currentStepUpValue = parseInt( currentStepUp.value );
	valCurrentPercent-=currentStepUpValue;
	SetCurrentPercent( id, valCurrentPercent );
}

function SetStepUpValue( id, val )
{
	var currentStepUp = document.getElementById( id + 'StepValue' );
	currentStepUp.value = val + '';
}

//	timer section



</script>
</head>
<body>
<form>
<input type="text" id="timeString" value="">
<table id="ObjName" width="1000">
<tr>
	<td align="center">
		<input type="hidden" id="ObjNameCurrentPercent" value="0">
		<input type="hidden" id="ObjNameShowPercent" value="true">
		<input type="hidden" id="ObjNameStepValue" value="1">
		<div id="ObjNamePercentage">
			asdfdf
		</div>
	</td>
</tr>
<tr>
<td>
<table id="ObjNameprogressBox" border=1 height=15>
	<tr>
		<td>
			<table id="ObjNameprogressBar" bgcolor="darkblue" >
				<tr>
					<td>
					<td>
				<tr>
			</table>
		</td>
	</tr>
</table>
<td>
<tr>
</table>
</form>
<script>
	InitProgressBar( 'ObjName' );
	InitTimer();
	createTimeString();
	SetStepUpValue( 'ObjName', 13 );
</script>

<body>
</html>





you can copy-paste the code, and it will work just fine in FF. but not IE. i hope somebody can help me. what should i do to make this error gone in ie? thx.. EDIT: removing unneccesary buttons.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!