Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with ie

Status
Not open for further replies.

zinch

Programmer
Joined
Mar 31, 2006
Messages
1
Location
GB
can some one help please?
Code:
var i = 0;
function loading(){
				if(document.getElementById('storage').innerHTML == '<br>Your file(s) are uploading...'){			document.getElementById('storage').innerHTML = '<br>Your file(s) are uploading';
}else if(document.getElementById('storage').innerHTML == '<br>Your file(s) are uploading'){
					document.getElementById('storage').innerHTML = '<br>Your file(s) are uploading.';
}else if(document.getElementById('storage').innerHTML == '<br>Your file(s) are uploading.'){
					document.getElementById('storage').innerHTML = '<br>Your file(s) are uploading..';
}else if(document.getElementById('storage').innerHTML == '<br>Your file(s) are uploading..'){
					document.getElementById('storage').innerHTML = '<br>Your file(s) are uploading...';
}else{
					document.getElementById('storage').innerHTML = '<br>Your file(s) are uploading';
}

setTimeout('loading()',500);
}
this code does not work in ie but in firefox iv been working on it for a couple of hours and its realy enoying me. lol
can some one please help.
 
They represent html tag differently internally in upper/lower case. Do the comparison at uniform case to make a common basis.
[tt]
var i = 0;
function loading(){
if(document.getElementById('storage').innerHTML.toLowerCase() == '<br>Your file(s) are uploading...'.toLowerCase()){ document.getElementById('storage').innerHTML = '<br>Your file(s) are uploading';
}else if(document.getElementById('storage').innerHTML.toLowerCase() == '<br>Your file(s) are uploading'.toLowerCase()){
document.getElementById('storage').innerHTML = '<br>Your file(s) are uploading.';
}else if(document.getElementById('storage').innerHTML.toLowerCase() == '<br>Your file(s) are uploading.'.toLowerCase()){
document.getElementById('storage').innerHTML = '<br>Your file(s) are uploading..';
}else if(document.getElementById('storage').innerHTML.toLowerCase() == '<BR>Your file(s) are uploading..'.toLowerCase()){
document.getElementById('storage').innerHTML = '<br>Your file(s) are uploading...';
}else{
document.getElementById('storage').innerHTML = '<br>Your file(s) are uploading';
}

setTimeout('loading()',500);
}
[/tt]
 
zinch, you can shorten this up dramatically.
Since the only thing you are changing is the number of periods after the text then it is easier to just add a period onto the end until you have 4 then reset to the original text.
In my sample below I moved the <br>'s outside of the div to make appending the periods directly to the div easier.

Code:
<html>
<head>
<title></title>
<script type="text/javascript">
var cnt=0;
function loading() {
  if (cnt < 4) {
    document.getElementById('storage').innerHTML += '.';
    cnt++;
  }
  else {
    document.getElementById('storage').innerHTML = 'Your files(s) are uploading';
    cnt = 0;
  }
  setTimeout('loading()',500);
}
</script>
</head>
<body>
<br>
<div id="storage">Your files(s) are uploading</div>
<br>
<input type="button" value="Test" onclick="loading()">
</body>
</html>

I have not tested in anything but IE but I think it should work.


Stamp out, eliminate and abolish redundancy!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top