Forum Moderators: open
It has something to do with the "window.event.srcElement;" routine.
<script language="JavaScript">
<!-- //start hiding for older browsers
//create expand menu for previous pollsvar img1 = new Image();
//plus image
img1.src = "img/plus.gif";
var img2 = new Image();
//minus image
img2.src = "img/minus.gif";
//create expand menu
function doOutline() {
var srcId, srcElement, targetElement;
srcElement = window.event.srcElement;
if (srcElement.className.toUpperCase() == "LEVEL1" ¦¦ srcElement.className.toUpperCase() == "FAQ") {
srcID = srcElement.id.substr(0, srcElement.id.length-1);
targetElement = document.all(srcID + "s");
srcElement = document.all(srcID + "i");
if (targetElement.style.display == "none") {
targetElement.style.display = "";
if (srcElement.className == "LEVEL1") srcElement.src = img2.src;
} else {
targetElement.style.display = "none";
if (srcElement.className == "LEVEL1") srcElement.src = img1.src;
}
}
}
document.onclick = doOutline;
-->
</script>
You're right about window.event.srcElement being IE-only. So instead of using
srcElement = window.event.srcElement;
try something like
function doOutline(e) { // note the e!
var srcId, srcElement, targetElement;
if (window.event) e = window.event;
srcElement = e.srcElement? e.srcElement : e.target;
// etc.
Next problem you may run into is document.all, which is an IE-only collection. Unless you care about IE4, it's perfectly safe to switch to using document.getElementById(), which is supported by IE5 and up, and by proper browsers such as Mozilla (inlcuding Firefox) and Opera.
<FORM>
<INPUT TYPE="button" VALUE="a button" ONCLICK="
var ctrlKey = document.layers? event.modifiers & Event.CONTROL_MASK : event.ctrlKey;
var shftKey = document.layers? event.modifiers & Event.CONTROL_MASK : event.shiftKey;
if (window.event) e = window.event;
var srcEl = e.srcElement? e.srcElement : e.target;
if (ctrlKey) alert(srcEl.tagName);
if (shftKey) alert(event.type);
if (!(shftKey¦¦ctrlKey)) alert('So why didn\'t you press any keys?');">
</FORM>