I have adapted a script from w3schools to use as a main menu for my site.
It works great in IE, but about 3 or 4 times slower in FireFox, Chrome and Safari!
I have no idea what might be wrong and would appreciate any help.
Many thanks
Mark
<html>
<head>
<script>
function showUser(str)
{
if (str=="")
{
document.getElementById("hoverbar").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("hoverbar").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","menulookuptest.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<div class='divcolor1' onmouseover='showUser("1")'>Option 1</div>
<div class='divcolor2' onmouseover='showUser("2")'>Option 2</div>
<div class='divcolor3' onmouseover='showUser("3")'>Option 3</div>
<div class='divcolor4' onmouseover='showUser("4")'>Option 4</div>
<div class='divcolor5' onmouseover='showUser("5")'>Option 5</div>
<div class='divcolor6' onmouseover='showUser("6")'>Option 6</div>
<div class='divcolor7' onmouseover='showUser("7")'>Option 7</div>
<div class='divcolor8' onmouseover='showUser("8")'>Option 8</div>
<div id="hoverbar">Content Goes Here</div>
</body>
</html>
menulookuptest.php
<?php
$q = $_GET['q'];
$con=mysqli_connect("localhost","root","PASS","DBNAME");
mysqli_select_db($con,"ajax_demo");
$sql="SELECT pagetitle, pagedept FROM intranetpage WHERE pagedept = '".$q."'";
$result = mysqli_query($con,$sql);
while($row = mysqli_fetch_array($result))
{
echo $row['pagetitle'];
echo "<BR>";
}
?>