js脚本在火狐浏览器中不兼容怎么办啊 对JS不是很了解 请高手帮忙修改 这个在IE中是好用的
代码如下
<script LANGUAGE="JavaScript">
document.onmouseover = doDocumentOnMouseOver ;
document.onmouseout = doDocumentOnMouseOut ; function doDocumentOnMouseOver() {
var eSrc = window.event.srcElement ;
if (eSrc.className == "item") {
window.event.srcElement.className = "highlight";
}
} function doDocumentOnMouseOut() {
var eSrc = window.event.srcElement ;
if (eSrc.className == "highlight") {
window.event.srcElement.className = "item";
}
}
var bV=parseInt(navigator.appVersion);
NS4=(document.layers) ? true : false;
IE4=((document.all)&&(bV>=4))?true:false;
ver4 = (NS4 || IE4) ? true : false;function expandIt(){return}
function expandAll(){return}
</script><script LANGUAGE="JavaScript1.2">
<!--
isExpanded = false;function getIndex(el) {
ind = null;
for (i=0; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.id == el) {
ind = i;
break;
}
}
return ind;
}function arrange() {
nextY = document.layers[firstInd].pageY + document.layers[firstInd].document.height;
for (i=firstInd+1; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.visibility != "hide") {
whichEl.pageY = nextY;
nextY += whichEl.document.height;
}
}
}function initIt(){
if (NS4) {
for (i=0; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.id.indexOf("Child") != -1) whichEl.visibility = "hide";
}
arrange();
}
else {
tempColl = document.all.tags("DIV");
for (i=0; i<tempColl.length; i++) {
if (tempColl(i).className == "child") tempColl(i).style.display = "none";
}
}
}function expandIt(el) {
if (!ver4) return;
if (IE4) {expandIE(el)} else {expandNS(el)}
}function expandIE(el) {
whichEl = eval(el + "Child");
whichIm = eval(el+"Img"); if (whichEl.style.display == "none") {
whichEl.style.display = "block";
whichIm.src = "Images/Icon-.gif";
}
else {
whichEl.style.display = "none";
whichIm.src = "Images/Icon+.gif";
}
window.event.cancelBubble = true ;
}function expandNS(el) {
whichEl = eval("document." + el + "Child");
whichIm = eval("document." + el + "Parent.document.images['imEx']");
if (whichEl.visibility == "hide") {
whichEl.visibility = "show";
whichIm.src = "Images/Icon-.gif";
}
else {
whichEl.visibility = "hide";
whichIm.src = "Images/Icon+.gif";
}
arrange();
}function showAll() {
for (i=firstInd; i<document.layers.length; i++) {
whichEl = document.layers[i];
whichEl.visibility = "show";
}
}function expandAll(isBot) {
newSrc = (isExpanded) ? "Images/Icon+.gif" : "Images/Icon-.gif"; if (NS4) {
for (i=firstInd; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.id.indexOf("Parent") != -1) {
whichEl.document.images["imEx"].src = newSrc;
}
if (whichEl.id.indexOf("Child") != -1) {
whichEl.visibility = (isExpanded) ? "hide" : "show";
}
} arrange();
if (isBot && isExpanded) scrollTo(0,document.layers[firstInd].pageY);
}
else {
divColl = document.all.tags("DIV");
for (i=0; i<divColl.length; i++) {
if (divColl(i).className == "child") {
divColl(i).style.display = (isExpanded) ? "none" : "block";
}
}
imColl = document.images.item("imEx");
for (i=0; i<imColl.length; i++) {
imColl(i).src = newSrc;
}
} isExpanded = !isExpanded;
}
//定义字体颜色
with (document) {
write("<STYLE TYPE='text/css'>");
if (NS4)
{
write(".parent {font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000; text-decoration:none; position:absolute; visibility:hidden; color: black;}");
write(".child {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt;color: #000000; position:absolute; visibility:hidden}");
write(".item { color: blue; text-decoration:none;}");
write(".regular {font-family: Arial,Helvetica,sans-serif; position:absolute; visibility:hidden}");
write("DIV { color:black; }")
}
else
{
write(".child {font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000; text-decoration:none; display:none}");
write(".parent {font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000; text-decoration:none;}");
write(".item { color:blue; text-decoration:none; font-size: 9pt;}");
write(".items { color:blue; text-decoration:none; font-size: 9pt;}");
write(".highlight { color: #0166b4; font-size: 9pt;}");
write(".heada { color: black;font: 12px; Times}");
write("DIV { color:black; }")
}
write("</STYLE>");}onload = initIt;
//-->
</script>
代码如下
<script LANGUAGE="JavaScript">
document.onmouseover = doDocumentOnMouseOver ;
document.onmouseout = doDocumentOnMouseOut ; function doDocumentOnMouseOver() {
var eSrc = window.event.srcElement ;
if (eSrc.className == "item") {
window.event.srcElement.className = "highlight";
}
} function doDocumentOnMouseOut() {
var eSrc = window.event.srcElement ;
if (eSrc.className == "highlight") {
window.event.srcElement.className = "item";
}
}
var bV=parseInt(navigator.appVersion);
NS4=(document.layers) ? true : false;
IE4=((document.all)&&(bV>=4))?true:false;
ver4 = (NS4 || IE4) ? true : false;function expandIt(){return}
function expandAll(){return}
</script><script LANGUAGE="JavaScript1.2">
<!--
isExpanded = false;function getIndex(el) {
ind = null;
for (i=0; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.id == el) {
ind = i;
break;
}
}
return ind;
}function arrange() {
nextY = document.layers[firstInd].pageY + document.layers[firstInd].document.height;
for (i=firstInd+1; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.visibility != "hide") {
whichEl.pageY = nextY;
nextY += whichEl.document.height;
}
}
}function initIt(){
if (NS4) {
for (i=0; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.id.indexOf("Child") != -1) whichEl.visibility = "hide";
}
arrange();
}
else {
tempColl = document.all.tags("DIV");
for (i=0; i<tempColl.length; i++) {
if (tempColl(i).className == "child") tempColl(i).style.display = "none";
}
}
}function expandIt(el) {
if (!ver4) return;
if (IE4) {expandIE(el)} else {expandNS(el)}
}function expandIE(el) {
whichEl = eval(el + "Child");
whichIm = eval(el+"Img"); if (whichEl.style.display == "none") {
whichEl.style.display = "block";
whichIm.src = "Images/Icon-.gif";
}
else {
whichEl.style.display = "none";
whichIm.src = "Images/Icon+.gif";
}
window.event.cancelBubble = true ;
}function expandNS(el) {
whichEl = eval("document." + el + "Child");
whichIm = eval("document." + el + "Parent.document.images['imEx']");
if (whichEl.visibility == "hide") {
whichEl.visibility = "show";
whichIm.src = "Images/Icon-.gif";
}
else {
whichEl.visibility = "hide";
whichIm.src = "Images/Icon+.gif";
}
arrange();
}function showAll() {
for (i=firstInd; i<document.layers.length; i++) {
whichEl = document.layers[i];
whichEl.visibility = "show";
}
}function expandAll(isBot) {
newSrc = (isExpanded) ? "Images/Icon+.gif" : "Images/Icon-.gif"; if (NS4) {
for (i=firstInd; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.id.indexOf("Parent") != -1) {
whichEl.document.images["imEx"].src = newSrc;
}
if (whichEl.id.indexOf("Child") != -1) {
whichEl.visibility = (isExpanded) ? "hide" : "show";
}
} arrange();
if (isBot && isExpanded) scrollTo(0,document.layers[firstInd].pageY);
}
else {
divColl = document.all.tags("DIV");
for (i=0; i<divColl.length; i++) {
if (divColl(i).className == "child") {
divColl(i).style.display = (isExpanded) ? "none" : "block";
}
}
imColl = document.images.item("imEx");
for (i=0; i<imColl.length; i++) {
imColl(i).src = newSrc;
}
} isExpanded = !isExpanded;
}
//定义字体颜色
with (document) {
write("<STYLE TYPE='text/css'>");
if (NS4)
{
write(".parent {font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000; text-decoration:none; position:absolute; visibility:hidden; color: black;}");
write(".child {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt;color: #000000; position:absolute; visibility:hidden}");
write(".item { color: blue; text-decoration:none;}");
write(".regular {font-family: Arial,Helvetica,sans-serif; position:absolute; visibility:hidden}");
write("DIV { color:black; }")
}
else
{
write(".child {font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000; text-decoration:none; display:none}");
write(".parent {font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000; text-decoration:none;}");
write(".item { color:blue; text-decoration:none; font-size: 9pt;}");
write(".items { color:blue; text-decoration:none; font-size: 9pt;}");
write(".highlight { color: #0166b4; font-size: 9pt;}");
write(".heada { color: black;font: 12px; Times}");
write("DIV { color:black; }")
}
write("</STYLE>");}onload = initIt;
//-->
</script>
然后将这些代码分情况编写, 在IE,firefox,等浏览器下,会有不同的处理方法;
网上到处是判断浏览器的代码,随便找一段就行;代码还是自己调的好~