木有报错啊。能执行的。可能如楼上所说,其他代码影响了<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>This is title</title>
</head>
<body>
<script>
function pass(){check(1)}
function check(status) {
alert("1");
}
</script>
<input id="pass" type="button" value="test" onclick="pass()" />
</body>
</html>

解决方案 »

  1.   

    你怎么定义的那个方法,是window作用域下的没有,还是放到其他的函数内部定义了,这样window域下是看不到这个函数的
      

  2.   

    chrome,ie,firefox测试#2代码都没有问题应该是其他地方定义过pass方法什么了
      

  3.   

    找到影响的文件了,是一个引入的js,去掉它就好了,可是这个js是怎么造成找不到pass方法的呢?
      

  4.   

    function formatNumber(number, pattern) {
    var str = number.toString();
    var strInt;
    var strFloat;
    var formatInt;
    var formatFloat;
    if (/\./g.test(pattern)) {
    formatInt = pattern.split(".")[0];
    formatFloat = pattern.split(".")[1];
    } else {
    formatInt = pattern;
    formatFloat = null;
    }
    if (/\./g.test(str)) {
    if (formatFloat != null) {
    var tempFloat = Math.round(parseFloat("0." + str.split(".")[1]) * Math.pow(10, formatFloat.length)) / Math.pow(10, formatFloat.length);
    strInt = (Math.floor(number) + Math.floor(tempFloat)).toString();
    strFloat = /\./g.test(tempFloat.toString()) ? tempFloat.toString().split(".")[1] : "0";
    } else {
    strInt = Math.round(number).toString();
    strFloat = "0";
    }
    } else {
    strInt = str;
    strFloat = "0";
    }
    if (formatInt != null) {
    var outputInt = "";
    var zero = formatInt.match(/0*$/)[0].length;
    var comma = null;
    if (/,/g.test(formatInt)) {
    comma = formatInt.match(/,[^,]*/)[0].length - 1;
    }
    var newReg = new RegExp("(\\d{" + comma + "})", "g");
    if (strInt.length < zero) {
    outputInt = new Array(zero + 1).join("0") + strInt;
    outputInt = outputInt.substr(outputInt.length - zero, zero);
    } else {
    outputInt = strInt;
    }
    var outputInt = outputInt.substr(0, outputInt.length % comma) + outputInt.substring(outputInt.length % comma).replace(newReg, (comma != null ? "," : "") + "$1");
    outputInt = outputInt.replace(/^,/, "");
    strInt = outputInt;
    }
    if (formatFloat != null) {
    var outputFloat = "";
    var zero = formatFloat.match(/^0*/)[0].length;
    if (strFloat.length < zero) {
    outputFloat = strFloat + new Array(zero + 1).join("0");
    //outputFloat        = outputFloat.substring(0,formatFloat.length);
    var outputFloat1 = outputFloat.substring(0, zero);
    var outputFloat2 = outputFloat.substring(zero, formatFloat.length);
    outputFloat = outputFloat1 + outputFloat2.replace(/0*$/, "");
    } else {
    outputFloat = strFloat.substring(0, formatFloat.length);
    }
    strFloat = outputFloat;
    } else {
    if (pattern != "" || (pattern == "" && strFloat == "0")) {
    strFloat = "";
    }
    }
    return strInt + (strFloat == "" ? "" : "." + strFloat);
    }
    function checkFloat(number) {
    if (isNaN(number)) {
    alert("\u8bf7\u8f93\u5165\u6570\u5b57");
    return false;
    } else {
    return true;
    }
    }
    function checkInt(number) {
    var re = new RegExp("^-?\\d+$");
    if (!re.test(number)) {
    alert("\u8bf7\u8f93\u5165\u6574\u6570");
    return false;
    } else {
    return true;
    }
    }
    function convertToWeight(pm, number) {
    if (number.toString().indexOf(",") >= 0) {
    number = number.toString().replace(new RegExp(",", "gm"), "");
    }
    if (!checkFloat(number)) {
    return false;
    }
    var str = number.toString();
    var strFloat = str.substring(str.indexOf(".") + 4, str.indexOf(".") + 8);
    if ("" == strFloat || null == strFloat || "000" == strFloat || "00" == strFloat || "0" == strFloat) {
    return parseFloat(Math.round(number * 1000) / 1000).toFixed(3);
    } else {
    return parseFloat(Math.round(number * 1000000) / 1000000).toFixed(6);
    }
    }
    function convertToNumber(pm, number) {
    if (!checkInt(number)) {
    return false;
    }
    return number;
    }
    function convertToPrice(number) {
    if (!checkFloat(number)) {
    return false;
    }
    var str = number.toString();
    return parseFloat(Math.round(number * 100) / 100).toFixed(2);
    }
    //转换大写金额
    function convertCurrency(currencyDigits) {
    var MAXIMUM_NUMBER = 99999999999.99;
    var CN_ZERO = "\u96f6";
    var CN_ONE = "\u58f9";
    var CN_TWO = "\u8d30";
    var CN_THREE = "\u53c1";
    var CN_FOUR = "\u8086";
    var CN_FIVE = "\u4f0d";
    var CN_SIX = "\u9646";
    var CN_SEVEN = "\u67d2";
    var CN_EIGHT = "\u634c";
    var CN_NINE = "\u7396";
    var CN_TEN = "\u62fe";
    var CN_HUNDRED = "\u4f70";
    var CN_THOUSAND = "\u4edf";
    var CN_TEN_THOUSAND = "\u4e07";
    var CN_HUNDRED_MILLION = "\u4ebf";
    //var CN_SYMBOL = "¥:";
    var CN_SYMBOL = "";
    var CN_DOLLAR = "\u5143";
    var CN_TEN_CENT = "\u89d2";
    var CN_CENT = "\u5206";
    var CN_INTEGER = "\u6574";

    // Variables:
    var integral; // Represent integral part of digit number.
    var decimal; // Represent decimal part of digit number.
    var outputCharacters; // The output result.
    var parts;
    var digits, radices, bigRadices, decimals;
    var zeroCount;
    var i, p, d;
    var quotient, modulus;// Validate input string:
    currencyDigits = currencyDigits.toString();
    if (currencyDigits == "") {
    //alert("请输入要转换的数字!");
    return "";
    }
    if (currencyDigits.match(/[^,.\d]/) != null) {
    alert("\u6570\u5b57\u4e2d\u542b\u6709\u975e\u6cd5\u5b57\u7b26!");
    return "";
    }
    if ((currencyDigits).match(/^((\d{1,3}(,\d{3})*(.((\d{3},)*\d{1,3}))?)|(\d+(.\d+)?))$/) == null) {
    //alert("错误的数字格式!"); 
    return "";
    }

    // Normalize the format of input digits:
    currencyDigits = currencyDigits.replace(/,/g, ""); // Remove comma delimiters.
    currencyDigits = currencyDigits.replace(/^0+/, ""); // Trim zeros at the beginning.
    // Assert the number is not greater than the maximum number.
    if (Number(currencyDigits) > MAXIMUM_NUMBER) {
    alert("\u8d85\u51fa\u8f6c\u6362\u6700\u5927\u8303\u56f4!");
    return "";
    }

    // Process the coversion from currency digits to characters:
    // Separate integral and decimal parts before processing coversion:
    parts = currencyDigits.split(".");
    if (parts.length > 1) {
    integral = parts[0];
    decimal = parts[1];
    // Cut down redundant decimal digits that are after the second.
    decimal = decimal.substr(0, 2);
    } else {
    integral = parts[0];
    decimal = "";
    }
    // Prepare the characters corresponding to the digits:
    digits = new Array(CN_ZERO, CN_ONE, CN_TWO, CN_THREE, CN_FOUR, CN_FIVE, CN_SIX, CN_SEVEN, CN_EIGHT, CN_NINE);
    radices = new Array("", CN_TEN, CN_HUNDRED, CN_THOUSAND);
    bigRadices = new Array("", CN_TEN_THOUSAND, CN_HUNDRED_MILLION);
    decimals = new Array(CN_TEN_CENT, CN_CENT);
    // Start processing:
    outputCharacters = "";
    // Process integral part if it is larger than 0:
    if (Number(integral) > 0) {
    zeroCount = 0;
    for (i = 0; i < integral.length; i++) {
    p = integral.length - i - 1;
    d = integral.substr(i, 1);
    quotient = p / 4;
    modulus = p % 4;
    if (d == "0") {
    zeroCount++;
    } else {
    if (zeroCount > 0) {
    outputCharacters += digits[0];
    }
    zeroCount = 0;
    outputCharacters += digits[Number(d)] + radices[modulus];
    }
    if (modulus == 0 && zeroCount < 4) {
    outputCharacters += bigRadices[quotient];
    }
    }
    outputCharacters += CN_DOLLAR;
    }
    // Process decimal part if there is:
    if (decimal != "") {
    for (i = 0; i < decimal.length; i++) {
    d = decimal.substr(i, 1);
    if (d != "0") {
    outputCharacters += digits[Number(d)] + decimals[i];
    }
    }
    }
    // Confirm and return the final output string:
    if (outputCharacters == "") {
    outputCharacters = CN_ZERO + CN_DOLLAR;
    }
    if (decimal == "") {
    outputCharacters += CN_INTEGER;
    }
    outputCharacters = CN_SYMBOL + outputCharacters;
    return outputCharacters;
    }
    //打开对话框帮助
    function do_help(url) {
    window.open(url, "help");
    }
    function useGlassLayer(v) { //v6.0
    v = (v == "show") ? "visible" : (v == "hide") ? "hidden" : v;
    var lyr = document.getElementById("body");
    var layerStyle = lyr.style;
    layerStyle.width = document.body.clientWidth;
    layerStyle.height = document.body.clientHeight;
    if (v == "visible") {
    moveGlassLayer();
    }
    layerStyle.visibility = v;
    }
    function moveGlassLayer() {
    var lyr = document.getElementById("body");
    lyr.style.top = document.body.scrollTop + document.body.offsetHeight - document.body.clientHeight - 10;
    lyr.style.left = document.body.scrollLeft + document.body.offsetWidth - document.body.clientWidth - 30;
    setTimeout("moveGlassLayer();", 80);
    }
    function resizeGlassLayer() {
    var lyr = document.getElementById("body");
    var layerStyle = lyr.style;
    layerStyle.width = document.body.clientWidth;
    layerStyle.height = document.body.clientHeight;
    }
    function showGlass(msg) {
    if (msg == null) {
    msg = "";
    }
    document.getElementById("tip").innerHTML = msg;
    useGlassLayer("show");
    }
    function hideGlass() {
    useGlassLayer("hidden");
    }
    function openModalDialog(url, width, height) {
    return window.showModalDialog(url, "", "dialogWidth:" + width + ";dialogHeight:" + height + ";dialogTop:scree.height/2-60;dialogLeft:scree.width/2-150;status:no;resizable=yes");
    var sWidth = new String(width);
    if (sWidth.indexOf("p") < 0) {
    sWidth += "pt";
    }
    var sHeight = new String(height);
    if (sHeight.indexOf("p") < 0) {
    sHeight += "pt";
    }
    var sFeatures = "dialogHeight:" + sHeight;
    //sFeatures+=";dialogLeft:"+iXPos;
    //sFeatures+=";dialogTop:"+iYPos;
    sFeatures += ";dialogWidth:" + sWidth;
    sFeatures += ";center:yes"; //{ yes | no | 1 | 0 } The default is yes.
    sFeatures += ";help:no"; //{ yes | no | 1 | 0 } The default is yes.
    sFeatures += ";resizable:no"; //{ yes | no | 1 | 0 } The default is no.
    sFeatures += ";status:no"; //{ yes | no | 1 | 0 } The default is yes for untrusted and no for trusted dialog windows
    sWidth = null;
    sHeight = null;
    var result = window.showModalDialog(url, "", sFeatures);
    return result;
    }
    function MM_openBrWindow(theURL, winName, features) {
    window.open(theURL, winName, features);
    }
    function openModalDlgDefW(url) {
    return openModalDialog(url, "350pt", "300pt");
    }
    function openModalDlgDefH(url) {
    return openModalDialog(url, "300pt", "350pt");
    }
    function openModalDialogMap(url, width, height) {
    return openModalDialog(url, width, height);
    }
      

  5.   


    /**/
    /*
     *    消息构造  
     */
    function CLASS_MSN_MESSAGE(id, width, height, caption, title, message, target, action) {
    this.id = id;
    this.title = title;
    this.caption = caption;
    this.message = message;
    this.target = target;
    this.action = action;
    this.width = width ? width : 200;
    this.height = height ? height : 120;
    this.timeout = 150;
    this.speed = 20;
    this.step = 1;
    this.right = screen.width - 1;
    this.bottom = screen.height;
    this.left = this.right - this.width;
    this.top = this.bottom - this.height;
    this.timer = 0;
    this.pause = false;
    this.close = false;
    this.autoHide = false;
    }
    /**/
    /*  
     *    隐藏消息方法  
     */
    CLASS_MSN_MESSAGE.prototype.hide = function () {
    if (this.onunload()) {
    var offset = this.height > this.bottom - this.top ? this.height : this.bottom - this.top;
    var me = this;
    if (this.timer > 0) {
    window.clearInterval(me.timer);
    }
    var fun = function () {
    if (me.pause == false || me.close) {
    var x = me.left;
    var y = 0;
    var width = me.width;
    var height = 0;
    if (me.offset > 0) {
    height = me.offset;
    }
    y = me.bottom - height;
    if (y >= me.bottom) {
    window.clearInterval(me.timer);
    me.Pop.hide();
    } else {
    me.offset = me.offset - me.step;
    }
    me.Pop.show(x, y, width, height);
    }
    };
    this.timer = window.setInterval(fun, this.speed);
    }
    };
    /**/
    /*  
     *    消息卸载事件,可以重写  
     */
    CLASS_MSN_MESSAGE.prototype.onunload = function () {
    return true;
    };
    /**/
    /*  
     *    消息命令事件,要实现自己的连接,请重写它  
     *  
     */
    //CLASS_MSN_MESSAGE.prototype.oncommand = function(){
    //  if(this.action!="")
    //     window.parent.location.href=this.action;
    //CLASS_MSN_MESSAGE.prototype.oncommand = function(){
    //   window.parent.location.href=this.action;
    //}  
    /**/
    /*  
     *    消息显示方法  
     */
    CLASS_MSN_MESSAGE.prototype.show = function () {
    var oPopup = window.createPopup(); //IE5.5+  
    this.Pop = oPopup;
    var w = this.width;
    var h = this.height;
    var str = "<DIV style='BORDER-RIGHT: #455690 1px solid; BORDER-TOP: #a6b4cf 1px solid; Z-INDEX: 99999; LEFT: 0px; BORDER-LEFT: #a6b4cf 1px solid; WIDTH: " + w + "px; BORDER-BOTTOM: #455690 1px solid; POSITION: absolute; TOP: 0px; HEIGHT: " + h + "px; BACKGROUND-COLOR:#e6e6fa'>";
    str += "<TABLE style='BORDER-TOP: #ffffff 1px solid; BORDER-LEFT: #ffffff 1px solid' cellSpacing=0 cellPadding=0 width='100%' bgColor=#e6e6fa border=0>";
    str += "<TR>";
    str += "<TD style='FONT-SIZE: 12px;COLOR: #0f2c8c' width=30 height=24></TD>";
    str += "<TD style='PADDING-LEFT: 4px; FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR: #1f336b; PADDING-TOP: 4px' vAlign=center width='100%'>" + this.caption + "</TD>";
    str += "<TD style='PADDING-RIGHT: 2px; PADDING-TOP: 2px' vAlign=center align=right width=19>";
    str += "<SPAN title=\u5173\u95ed style='FONT-WEIGHT: bold; FONT-SIZE: 12px; CURSOR: hand; COLOR: red; MARGIN-RIGHT: 4px' id='btSysClose' >\xd7</SPAN></TD>";
    str += "</TR>";
    str += "<TR>";
    str += "<TD style='PADDING-RIGHT: 1px;PADDING-BOTTOM: 1px' colSpan=3 height=" + (h - 28) + ">";
    str += "<DIV style='BORDER-RIGHT: #b9c9ef 1px solid; PADDING-RIGHT: 8px; BORDER-TOP: #728eb8 1px solid; PADDING-LEFT: 8px; FONT-SIZE: 12px; PADDING-BOTTOM: 8px; BORDER-LEFT: #728eb8 1px solid; WIDTH: 100%; COLOR: #1f336b; PADDING-TOP: 8px; BORDER-BOTTOM: #b9c9ef 1px solid; HEIGHT: 100%'>" + this.title + "<BR><BR>";
    str += "<DIV style='WORD-BREAK: break-all' align=left id='btCommand'><FONT color=#ff0000 >" + this.message + "</FONT></DIV>";
    str += "</DIV>";
    str += "</TD>";
    str += "</TR>";
    str += "</TABLE>";
    str += "</DIV>";
    oPopup.document.body.innerHTML = str;
    this.offset = 0;
    var me = this;
    oPopup.document.body.onmouseover = function () {
    me.pause = true;
    };
    oPopup.document.body.onmouseout = function () {
    me.pause = false;
    };
    var fun = function () {
    var x = me.left;
    var y = 0;
    var width = me.width;
    var height = me.height;
    if (me.offset > me.height) {
    height = me.height;
    } else {
    height = me.offset;
    }
    y = me.bottom - me.offset;
    if (y <= me.top) {
    me.timeout--;
    if (me.timeout == 0) {
    window.clearInterval(me.timer);
    if (me.autoHide) {
    me.hide();
    }
    }
    } else {
    me.offset = me.offset + me.step;
    }
    me.Pop.show(x, y, width, height);
    };
    this.timer = window.setInterval(fun, this.speed);
    var btClose = oPopup.document.getElementById("btSysClose");
    btClose.onclick = function () {
    me.close = true;
    me.hide();
    };
    var btCommand = oPopup.document.getElementById("btCommand");
    ///btCommand.onclick = function()
    //{
    //  me.oncommand();
    //}    
    };
    /**/
    /* 
     ** 设置速度方法 
     **/
    CLASS_MSN_MESSAGE.prototype.speed = function (s) {
    var t = 20;
    try {
    t = praseInt(s);
    }
    catch (e) {
    }
    this.speed = t;
    };
    /**/
    /* 
     ** 设置步长方法 
     **/
    CLASS_MSN_MESSAGE.prototype.step = function (s) {
    var t = 1;
    try {
    t = praseInt(s);
    }
    catch (e) {
    }
    this.step = t;
    };
    CLASS_MSN_MESSAGE.prototype.rect = function (left, right, top, bottom) {
    try {
    this.left = left != null ? left : this.right - this.width;
    this.right = right != null ? right : this.left + this.width;
    this.bottom = bottom != null ? (bottom > screen.height ? screen.height : bottom) : screen.height;
    this.top = top != null ? top : this.bottom - this.height;
    }
    catch (e) {
    }
    };
    function showDiscussMsg(msg, href) {
    var x = new CLASS_MSN_MESSAGE("1", 200, 120, "\u7cfb\u7edf\u63d0\u793a\u6846", "\u6d3d\u8c08\u4fe1\u606f", msg, "", href);
    x.speed = 20;
    x.step = 5;
    x.show();
    }
    function selectList(selectName, selectedValue) {
    for (var i = 0; i < selectName.options.length; i++) {
    if (selectName.options[i].value == selectedValue) {
    selectName.options.selectedIndex = i;
    }
    }
    }
    function isNullOrBlank(inputName) {
    if (inputName == null || inputName.value == "" || inputName.value == "null") {
    return true;
    } else {
    return false;
    }
    }
    function isNotSelected(checkBoxName) {
    if (checkBoxName.length == null) {
    if (checkBoxName.checked == false) {
    return true;
    }
    } else {
    var num = -1;
    for (var i = 0; i < checkBoxName.length; i++) {
    if (checkBoxName[i].checked) {
    num = num + 1;
    }
    }
    if (num == -1) {
    return true;
    }
    }
    return false;
    }
    function isNotNumber(arrayName) {
    for (var i = 0; i < arrayName.length; i++) {
    if (isNaN(arrayName[i].value)) {
    alert("\ufffd\ubc34\ufffd\ufffd\u0237\ufffd\ufffd\ufffd\ufffd\u0778\ufffd\u02bd\ufffd\ufffd\ufffd\ufffd!");
    arrayName[i].focus();
    return false;
    }
    }
    }
    function isDate(dateStr) {
    if (dateStr == null || dateStr == "") {
    return false;
    }
    if (isNaN(dateStr)) {
    return false;
    }
    if (dateStr.length != 8) {
    return false;
    }
    var yearStr = dateStr.substring(0, 4);
    var monthStr = dateStr.substring(4, 6);
    var dayStr = dateStr.substring(6);
    var month_val, year_val, day_val;
    year_val = parseInt(yearStr, 10);
    month_val = parseInt(monthStr, 10);
    day_val = parseInt(dayStr, 10);
    if (year_val < 1900 || year_val > 3000) {
    return false;
    }
    if (month_val < 1 || month_val > 12) {
    return false;
    }
    switch (month_val) {
      case 1:
      case 3:
      case 5:
      case 7:
      case 8:
      case 10:
      case 12:
    if (day_val < 1 || day_val > 31) {
    return false;
    }
    break;
      case 4:
      case 6:
      case 9:
      case 11:
    if (day_val < 1 || day_val > 30) {
    return false;
    }
    break;
      case 2:
    if ((year_val % 4 == 0 && year_val % 100 != 0) || year_val % 400 == 0) {
    if (day_val < 1 || day_val > 29) {
    return false;
    }
    } else {
    if (day_val < 1 || day_val > 28) {
    return false;
    }
    }
    break;
      default:
    }
    return true;
    }
    function check_number(field, len1, len2) {
    var re = /^[0-9]{1,}\.{0,1}[0-9]{0,}0*$/;
    var js_value = field.value;
    if (js_value.length == 0) {
    return true;
    }
    if (js_value.match(re)) {
    var dot_position = js_value.indexOf(".");
    var int_value, dec_value;
    if (dot_position >= 0) {
    int_value = js_value.substring(0, dot_position);
    dec_value = js_value.substring(dot_position + 1);
    } else {
    int_value = js_value;
    dec_value = "";
    }
    if (int_value.length > len1) {
    alert("The integer digits are too long! It should be " + len1 + "digits");
    field.value = "";
    field.focus();
    return false;
    }
    if (dec_value.length > len2) {
    alert("The decimal digits are too long! It should be " + len2 + "digits");
    field.value = "";
    field.focus();
    return false;
    }
    return true;
    }
    alert("Please input a number!");
    field.value = "";
    field.focus();
    return false;
    }
      

  6.   

    <input id="pass" type="button" value="审批通过" class="button_op" onclick="pass()" />
    id和函数名一样了, 有些浏览器是直接能   id.value 这样获取值的。  IE8好像就行。 以前我也遇到过这样的问题,函数名称换一个或者id换一下
    你可以在按钮的点击事件中打印一下看看pass到底是什么
    document.getElementById("pass").onclick=function(){console.log(pass) ;}