Ciao a tutti ero gia' abbastanza avezzo alle follie del motore js di ie ma questa poi e' pua follia.
sto testanto le funzioni di sorting con array strutturati .. e nel momento un cui devo ordinare un array in maniera decrescente in base ad un campo di un oggetto messo in un array ... beh IE ne fa delle belle.
VI posto il codice di test, potete tranquillamente copiarlo ed incollarelo in una pagina .html e avviare la pagina c'e' solo del codice html e lo script di test.
Avviatelo su ff, chomre safari etc... e poi su ie9 ... ne vedrete delle belle
Avete idea di come farlo aprtire sotto ie ? A meno di non dover identificare il browser et invertire i controlli ?Codice PHP:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >
<html xmlns="http://www.w3.org/1999/xhtml" lang="it" xml:lang="it">
<head>
<title>TEST SORTING</title>
<script type="text/javascript">
var B1 = null ;
var B2 = null ;
var B1_STR = "" ;
function init()
{
B1 = document.getElementById( "execution" ) ;
B2 = document.getElementById( "result" ) ;
}
function startTest()
{
var a1 = [
{ id:1 },
{ id:2 },
{ id:3 },
{ id:5 },
{ id:6 },
{ id:7 },
]
B1_STR = "<pre>START SORTING\n-----------------------------\n" ;
var a2 = a1.sort( sorter )
B1_STR +="\n-----------------------------\nEND SORTING</pre>" ;
var str = "<pre>" ;
for( var i=0 ; i<a2.length ; i++ )
{
str += "["+i+"] => "+a2[i].id+"\n" ;
}
str += "</pre>" ;
B1.innerHTML = B1_STR ;
B2.innerHTML = str ;
}
function sorter( a,b )
{
B1_STR +=" ["+a.id+"] < ["+b.id+"] \n" ;
return a.id<b.id ;
}
</script>
</head>
<body onload="init()">
[url="javascript:startTest()"]START TEST !!!!! [/url]
<table width="500">
<tr>
<td width="50%">EXECUTION</td>
<td width="50%">RESULT</td>
</tr>
<tr>
<td valign="top"><div id="execution"></div></td>
<td valign="top"><div id="result"></div></td>
</tr>
</table>
</body></html>
Grassie.

Rispondi quotando
