
一段JS写的导航条代码,在IE,CHROME下正常,在FIREFOX下无法显示效果。 代码没完,如果需要可以留qq
varselectedItem=null;vartargetWin;document.onclick=handleClick;document.onmouseover=h...
var selectedItem = null;
var targetWin;
document.onclick = handleClick;
document.onmouseover = handleOver;
document.onmouseout = handleOut;
document.onmousedown = handleDown;
document.onmouseup = handleUp;
document.write(writeSubPadding(10)); //write the stylesheet for the sub. Getting the indention right
function handleClick() {
el = getReal(window.event.srcElement, "tagName", "DIV");
if ((el.className == "topFolder") || (el.className == "subFolder")) {
// if (el.sub == null) el.sub = eval(el.id + "Sub");
// alert(el.sub);
el.sub = eval(el.id + "Sub");
if (el.sub.style.display == null) el.sub.style.display = "none";
if (el.sub.style.display != "block") { //hidden
//any other sub open?
if (el.parentElement.openedSub != null) {
var opener = eval(el.parentElement.openedSub + ".opener");
hide(el.parentElement.openedSub);
if (opener.className == "topFolder")
outTopItem(opener);
}
el.sub.style.display = "block";
el.sub.parentElement.openedSub = el.sub.id;
el.sub.opener = el;
}
else {
if (el.sub.openedSub != null) hide(el.sub.openedSub);
else hide(el.sub.id);
}
}
if ((el.className == "subItem") || (el.className == "subFolder")) {
if (selectedItem != null)
restoreSubItem(selectedItem);
highlightSubItem(el);
}
if ((el.className == "topItem") || (el.className == "topFolder")) {
if (selectedItem != null)
restoreSubItem(selectedItem);
}
if ((el.className == "topItem") || (el.className == "subItem")) {
if ((el.href != null) && (el.href != "")) {
if ((el.target == null) || (el.target == "")) {
if (window.opener == null) {
// alert(document.all.tags("BASE").item(0));
if (document.all.tags("BASE").item(0) != null)
// eval(document.all.tags("BASE").item(0).target + ".location = el.href");
window.open(el.href, document.all.tags("BASE").item(0).target);
else
window.location = el.href; // HERE IS THE LOADING!!!
}
else {
window.opener.location = el.href;
}
}
else {
window.open(el.href, el.target);
// eval(el.target + ".location = el.href");
}
}
}
var tmp = getReal(el, "className", "favMenu");
if (tmp.className == "favMenu") fixScroll(tmp);
}
function handleOver() {
var fromEl = getReal(window.event.fromElement, "tagName", "DIV");
var toEl = getReal(window.event.toElement, "tagName", "DIV");
if (fromEl == toEl) return;
el = toEl;
if ((el.className == "topFolder") || (el.className == "topItem")) overTopItem(el);
if ((el.className == "subFolder") || (el.className == "subItem")) overSubItem(el);
……………… 展开
var targetWin;
document.onclick = handleClick;
document.onmouseover = handleOver;
document.onmouseout = handleOut;
document.onmousedown = handleDown;
document.onmouseup = handleUp;
document.write(writeSubPadding(10)); //write the stylesheet for the sub. Getting the indention right
function handleClick() {
el = getReal(window.event.srcElement, "tagName", "DIV");
if ((el.className == "topFolder") || (el.className == "subFolder")) {
// if (el.sub == null) el.sub = eval(el.id + "Sub");
// alert(el.sub);
el.sub = eval(el.id + "Sub");
if (el.sub.style.display == null) el.sub.style.display = "none";
if (el.sub.style.display != "block") { //hidden
//any other sub open?
if (el.parentElement.openedSub != null) {
var opener = eval(el.parentElement.openedSub + ".opener");
hide(el.parentElement.openedSub);
if (opener.className == "topFolder")
outTopItem(opener);
}
el.sub.style.display = "block";
el.sub.parentElement.openedSub = el.sub.id;
el.sub.opener = el;
}
else {
if (el.sub.openedSub != null) hide(el.sub.openedSub);
else hide(el.sub.id);
}
}
if ((el.className == "subItem") || (el.className == "subFolder")) {
if (selectedItem != null)
restoreSubItem(selectedItem);
highlightSubItem(el);
}
if ((el.className == "topItem") || (el.className == "topFolder")) {
if (selectedItem != null)
restoreSubItem(selectedItem);
}
if ((el.className == "topItem") || (el.className == "subItem")) {
if ((el.href != null) && (el.href != "")) {
if ((el.target == null) || (el.target == "")) {
if (window.opener == null) {
// alert(document.all.tags("BASE").item(0));
if (document.all.tags("BASE").item(0) != null)
// eval(document.all.tags("BASE").item(0).target + ".location = el.href");
window.open(el.href, document.all.tags("BASE").item(0).target);
else
window.location = el.href; // HERE IS THE LOADING!!!
}
else {
window.opener.location = el.href;
}
}
else {
window.open(el.href, el.target);
// eval(el.target + ".location = el.href");
}
}
}
var tmp = getReal(el, "className", "favMenu");
if (tmp.className == "favMenu") fixScroll(tmp);
}
function handleOver() {
var fromEl = getReal(window.event.fromElement, "tagName", "DIV");
var toEl = getReal(window.event.toElement, "tagName", "DIV");
if (fromEl == toEl) return;
el = toEl;
if ((el.className == "topFolder") || (el.className == "topItem")) overTopItem(el);
if ((el.className == "subFolder") || (el.className == "subItem")) overSubItem(el);
……………… 展开
展开全部
事件注册的方式,浏览器和浏览器都不太一样,建议你看下,貌似直接给事件方法,FF是不支持的,必须使用注册监听的方式。你可以参考一下《JAVASCRIPT权威指南》的关于事件注册的章节,写的很清楚
参考资料: JAVASCRIPT权威指南
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询