日期:2014-05-19  浏览次数:20442 次

javascript脚本传参问题
我的页面上需要用到这样一段脚本
function   PopupConfirm(str)
{
    var   strInfo   =   str;
    if   (window.showModalDialog)
    {
        var   strReturnValue= " ";
        var   width;
        if(strInfo.length   <   20)
        {
            width   =   strInfo.length   *   20;
        }
        else
        {
            width   =   400;
        }
        strReturnValue   =   window.showModalDialog( "PopupConfirm.aspx ",      
            str,   "dialogWidth= "   +   width   +   "px;dialogHeight=130px;scroll=no;
            status=no;help=no;center=yes ");
        var   ConfirmResult   =   document.getElementById( "txtConfirmResult ");
        ConfirmResult.value   =   strReturnValue;
        }
}

当我把这段脚本放在aspx页面中间的head中运行时是正常的,而把这段脚本移到
一个公用的common.js文件中,然后在aspx页面中引入这个common.js的时候总是
报告这个函数的参数str未定义,这是咋回事?

------解决方案--------------------
如果代码完全一样,那就是常见的编码问题,将common.js另存为utf-8格式