Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Problem with mouse highlighting using innerhtml


Message #1 by "Kevin Crofts" <kevinc@l...> on Tue, 24 Jul 2001 12:07:22 +0100
This Script basically loads a category of film i.e Action,Comedy,Romance 
etc. as a set of directories on the hard disk drive. Each directory 
contains a movie with the name of the movie as the title i.e "Sleepless 
in Seattle.mpg". Everything works OK except that when the category is 
selected and the movies displayed for that category I get an 
'over-spill' of the highlighted text when I move the mouse. If I click 
anywhere on the page using the mouse then the 'highlighting' disappears. 
Does anyone know how to get rid of this annoying feature.
cheers,
Kevin
<HTML>
<HEAD>
<TITLE>Movie list</TITLE>
</HEAD>
<BODY topmargin=3D"0" leftmargin=3D"0" rightmargin=3D"0" 
bottommargin=3D"0" marginheight=3D"0" marginwidth=3D"0" 
bgcolor=3D"#336699">
<table id=3Dmovies width=3D"408" border=3D"0" cellspacing=3D"0" 
cellpadding=3D"0" height=3D"186">
</table>

<script language=3D"JScript" type=3D"text/jscript">

function fillup(){

var myFileSystem=3Dnew ActiveXObject("Scripting.FileSystemObject");


var myFolder=3DmyFileSystem.GetFolder("c:\\movies");



var fc =3D new Enumerator(myFolder.SubFolders);
var i=3D1;
var k=3D0;
var len;
var obj;
var buildhtml=3D"";
var oRow;
var oCell;



  for (; !fc.atEnd(); fc.moveNext())
 {


 obj=3D"'";
 obj+=3Dfc.item().Name;
 obj+=3D"'";
 buildhtml=3D"";
 buildhtml+=3D"\n<DIV"
 +"\n onmouseover=3D\"this.style.color=3D'#999999'\""
 +"\n onmouseout=3D\"this.style.color=3D'#FFFFFF'\""
 +"\n onmouseup=3D\"ShowFileList("
 +obj
 + ")\""
 +">"
 +fc.item().Name
 +"</DIV>"




 oRow =3D movies.insertRow();

 oCell =3D oRow.insertCell();
 oCell.style.fontSize=3D "30";
 oCell.style.color=3D "#FFFFFF";
 oCell.style.fontFamily=3D"Verdana, Arial, Helvetica, sans-serif";


 oCell.innerHTML=3Dbuildhtml;
i=3Di+1;
k=3Dk+1;


}


 oCell.innerHTML=3Dbuildhtml;

delete myFileSystem;


}
function ShowFileList(name)
{


var myFileSystem=3Dnew ActiveXObject("Scripting.FileSystemObject");
var foldername=3D"c:\\movies\\";

 foldername+=3Dname;

var myFolder=3DmyFileSystem.GetFolder(foldername);

var myFiles=3DmyFolder.Files;

var fc =3D new Enumerator(myFiles);
var i=3D1;
var k=3D0;
var len;
var str;
var buildhtml=3D"";
var moviename=3D"'";
var count=3D0;
var j=3D0;
var oRow;
var oCell;
var curr_row=3D0;
var curr_cell;

while (!fc.atEnd())
{

 buildhtml=3D"";
 len=3Dfc.item().Name.length;
 str=3Dfc.item().Name.substring(0,len-4);
  moviename=3D"'";
 moviename+=3Dname;
 moviename+=3D"\\\\"+fc.item().Name;
 moviename+=3D"'";

 buildhtml+=3D"<DIV"
 +"\n onmouseover=3D\"this.style.color=3D'#999999'\""
 +"\n onmouseout=3D\"this.style.color=3D'#FFFFFF'\""
 +">"
 +str
 +"</DIV>";

 if (curr_row >=3D movies.rows.length)
 {

 oRow =3D movies.insertRow();

 oCell =3D oRow.insertCell();
 oCell.style.fontSize=3D "30";

 oCell.style.color=3D "#FFFFFF";
 oCell.style.fontFamily=3D"Verdana, Arial, Helvetica, sans-serif";

 oRow.cells[0].innerHTML=3D buildhtml;
 }
 else
 {
   oRow =3D movies.rows[curr_row];
 oRow.cells[0].innerHTML=3D buildhtml;
 }

 curr_row=3Dcurr_row+1;

 fc.moveNext();

}


 k=3Dmovies.rows.length;

 if (curr_row < k)
 {

  do
  {

  movies.deleteRow(curr_row);
  } while(movies.rows.length > curr_row);
 }
delete myFileSystem;
}
window.onload=3Dfillup
</script>
</BODY>
</HTML>



  Return to Index