红狐下的一段JS报错ReferenceError: event is not defined,晚上其他方法试了不好用
火狐下的一段JS报错ReferenceError: event is not defined,晚上其他方法试了不好用
火狐下的一段JS报错ReferenceError: event is not defined ,请问怎么解决。
我的报错的JS 是一段表格隔行换色的JS ,如下所示:
火狐下的一段JS报错ReferenceError: event is not defined ,请问怎么解决。
我的报错的JS 是一段表格隔行换色的JS ,如下所示:
var highlightcolor = '#d5f4fe';
var clickcolor='#51b2f6';//此处clickcolor只能用win系统颜色代码才能成功,如果用#xxxxxx的代码就不行,还没搞清楚为什么:(
function changeto(){
source = event.srcElement;
if(source.tagName=="TR"||source.tagName=="TABLE"){
return false;
}
while(source.tagName != "TD"){
source = source.parentElement;
}
source = source.parentElement;
cs = source.children;
//alert(cs.length);
if(cs[1]!=null)
{
if(cs[1].style!=null)
{
if(cs[1].style.backgroundColor!=highlightcolor&&cs[1].style.backgroundColor!=clickcolor){
for(var i=0;i<cs.length;i++){
cs[i].style.backgroundColor=highlightcolor;
}
}
}
}
}
function changeback(){
source = event.srcElement;
if(event.fromElement.contains(event.toElement)||source.contains(event.toElement)){
return false;
}
if(event.toElement!=source&&cs[1].style.backgroundColor!=clickcolor){
//source.style.backgroundColor=originalcolor
for(var i=0;i<cs.length;i++){
cs[i].style.backgroundColor="";
}
}
}
function clickto(){
source = event.srcElement;
if(source.tagName=="TR"||source.tagName=="TABLE"){
return;
}
while(source.tagName!="TD"){
source = source.parentElement;
}
source = source.parentElement;
cs = source.children;
//alert(cs.length);
if(cs[1].style.backgroundColor!=clickcolor&&source.id!="nc"){
for(var i=0;i<cs.length;i++){
cs[i].style.backgroundColor=clickcolor;
}
}else{
for(var i=0;i<cs.length;i++){
cs[i].style.backgroundColor="";
}
}
}
function toPage(url,urlparamater){
var toPageValue = document.getElementById("toPage").value;
if(toPageValue!=""){
window.location.href = url + '?page=' + toPageValue+urlparamater;
}
}
function openWin(u, w, h ) {
var l = (screen.width - w) / 2;
var t = (screen.height - h) / 2;
var s = 'width=' + w + ', height=' + h + ', top=' + t + ', left=' + l;
s += ', toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no';
open(u, 'oWin', s);
}
/**
* 使用ajax提交数据
*/
function ajax_post(the_url,succ_callback){
$.ajax({
type:'POST',
url:the_url,
success:succ_callback,
error:function(){
alert("提交数据失败,请稍候再试");
}
});
}
function ajax_post(the_url,the_param,succ_callback){
$.ajax({
type:'POST',
url:the_url,
data:the_param,
success:succ_callback,
error:function(){
alert("提交数据失败,请稍候再试");
}
});
}
function getFormatDate() {
var currentDate = new Date();
var nowYear = 0;
var nowMonth = 0;
var nowDay = 0;
var formatDate = "";
//初始化时间
nowYear = currentDate.getFullYear();
nowMonth = currentDate.getMonth() + 1;
nowDay = currentDate.getDate();
formatDate += nowYear + "-";
if (nowMonth >= 10 )
{
formatDate += nowMonth + "-";
}
else
{
formatDate += "0" + nowMonth + "-";
}
if (nowDay >= 10 )
{
formatDate += nowDay;
}
else
{
formatDate += "0" + nowDay;
}
return formatDate;
}
function alertMsg(msg){
if($("#dialogalert").length == 0){
$("body").append('<div id="dialogalert"></div>');
$("#dialogalert").dialog({
autoOpen:false,
title:'提示',
modal: true,
width:260,
closeOnEscape:true,
buttons:{
'[关闭]':function(){