jquery messageBox插件在IE7中不起作用

jquery messageBox插件在IE7中不起作用,jquery,jquery-plugins,internet-explorer-7,messagebox,Jquery,Jquery Plugins,Internet Explorer 7,Messagebox,我正在使用这个插件。但是这个插件在IE7中不起作用 有人能帮我解决这个问题吗..请告诉我问题出在哪里..为什么这个插件在IE7中不起作用。提前谢谢你无论如何…问题在这里解决了,更新的插件代码 /* jQuery.msgBox plugi-in Copyright 2011, Halil İbrahim Kalyoncu */ jQuery.msgBox = msg; function msg (options) { var isShown = false; var typeOf

我正在使用这个插件。但是这个插件在IE7中不起作用


有人能帮我解决这个问题吗..请告诉我问题出在哪里..为什么这个插件在IE7中不起作用。提前谢谢你

无论如何…问题在这里解决了,更新的插件代码

/*
jQuery.msgBox plugi-in 
Copyright 2011, Halil İbrahim Kalyoncu
*/
jQuery.msgBox = msg;
function msg (options) {
    var isShown = false;
    var typeOfValue = typeof options;
    var defaults = {
        content: (typeOfValue == "string" ? options : "Message"),
        title: "Warning",
        type: "alert",
        autoClose: false,
        timeOut: 0,
        showButtons: true,
        buttons: [{ value: "Ok"}],
        inputs: [{ type: "text", name:"userName", header: "User Name" }, { type: "password",name:"password", header: "Password"}],
        success: function (result) { },
        beforeShow: function () { },
        afterShow: function () { },
        beforeClose: function () { },
        afterClose: function () { },
        opacity: 0.1
    };
    options = typeOfValue == "string" ? defaults : options;
    if (options.type != null) {
        switch (options.type) {
            case "alert":
                options.title = options.title == null ? "Warning" : options.title;
                break;
            case "info":
                options.title = options.title == null ? "Information" : options.title;
                break;
            case "error":
                options.title = options.title == null ? "Error" : options.title;
                break;
            case "confirm":
                options.title = options.title == null ? "Confirmation" : options.title;
                options.buttons = options.buttons == null ? [{ value: "Yes" }, { value: "No" }, { value: "Cancel"}] : options.buttons;
                break;
            case "prompt":
                options.title = options.title == null ? "Log In" : options.title;
                options.buttons = options.buttons == null ? [{ value: "Login" }, { value: "Cancel"}] : options.buttons;
                break;
            default:
                image = "alert.png";
        }
    }
    options.timeOut = options.timeOut == null ? (options.content == null ? 500 : options.content.length * 70) : options.timeOut;
    options = $.extend(defaults, options);
    if (options.autoClose) {
        setTimeout(hide, options.timeOut);
    }
    var image = "";
    switch (options.type) {
        case "alert":
            image = "alert.png";
            break;
        case "info":
            image = "info.png";
            break;
        case "error":
            image = "error.png";
            break;
        case "confirm":
            image = "confirm.png";
            break;
        default:
            image = "alert.png";
    }

    var buttons = "";
    $(options.buttons).each(function (index, button) {
        buttons += "<input class=\"msgButton\" type=\"button\" name=\"" + button.value + "\" value=\"" + button.value + "\" />";
    });

    var inputs = "";
    $(options.inputs).each(function (index, input) {
        var type = input.type;
        if (type=="checkbox" || type =="radio") {
            inputs += "<div class=\"msgInput\">" +
            "<input type=\"" + input.type + "\" name=\"" + input.name + "\" "+(input.checked == null ? "" : "checked ='"+input.checked+"'")+" value=\"" + (typeof input.value == "undefined" ? "" : input.value) + "\" />" +
            "<text>"+input.header +"</text>"+
            "</div>";
        }
        else {
            inputs += "<div class=\"msgInput\">" +
            "<span class=\"msgInputHeader\">" + input.header + "<span>" +
            "<input type=\"" + input.type + "\" name=\"" + input.name + "\" value=\"" + (typeof input.value == "undefined" ? "" : input.value) + "\" />" +
            "</div>";
        }
    });

    var divBackGround = "<div class=\"msgBoxBackGround\"></div>"
    var divTitle = "<div class=\"msgBoxTitle\">" + options.title + "</div>";
    var divContainer = "<div class=\"msgBoxContainer\"><div class=\"msgBoxImage\"><img src=\"../images/" + image + "\"/></div><div class=\"msgBoxContent\"><p><span>" + options.content + "</span></p></div></div>";
    var divButtons = "<div class=\"msgBoxButtons\">" + buttons + "</div>";
    var divInputs = "<div class=\"msgBoxInputs\">" + inputs + "</div>";

    if ($("div.msgBox").length == 0) {
        if (options.type == "prompt") {
            $("body").append(divBackGround + "<div class=\"msgBox\">" + divTitle + "<div>" + divContainer + (options.showButtons ? divButtons + "</div>" : "</div>") + "</div>");
            $("div.msgBoxImage").remove();
            $("div.msgBoxButtons").css({"text-align":"center","margin-top":"5px"});
            $("div.msgBoxContent").css({"width":"100%","height":"100%"});
            $("div.msgBoxContent").html(divInputs);
        }
        else {
            $("body").append(divBackGround + "<div class=\"msgBox\">" + divTitle + "<div>" + divContainer + (options.showButtons ? divButtons + "</div>" : "</div>") + "</div>");
        }
    }
    else {
        if (options.type == "prompt") {
            $("div.msgBox").html(divTitle + "<div>" + divContainer + (options.showButtons ? divButtons + "</div>" : "</div>"));
            $("div.msgBoxImage").remove();
            $("div.msgBoxContent").css("width", "100%");
            $("div.msgBoxContent").html(divInputs);
        }
        else {
            $("div.msgBox").html(divTitle + "<div>" + divContainer + (options.showButtons ? divButtons + "</div>" : "</div>"));
        }
    }

    var width = $("div.msgBox").width();
    var height = $("div.msgBox").height();
    var windowHeight = $(window).height();
    var windowWidth = $(window).width();

    var top = windowHeight / 2 - height / 2;
    var left = windowWidth / 2 - width / 2;

    show();

    function show() {
        if (isShown) {
            return;
        }
        $("div.msgBox").css({ opacity: 0, top: top - 50, left: left });
        $("div.msgBoxBackGround").css({ opacity: options.opacity });
        options.beforeShow();
        $("div.msgBoxBackGround").css({ "width": $(document).width(), "height": getDocHeight() });
        $("div.msgBox,div.msgBoxBackGround").fadeIn(0);
        $("div.msgBox").animate({ opacity: 1, "top": top, "left": left }, 200);
        setTimeout(options.afterShow, 200);
        isShown = true;
        $(window).bind("resize", function (e) {
            var width = $("div.msgBox").width();
            var height = $("div.msgBox").height();
            var windowHeight = $(window).height();
            var windowWidth = $(window).width();

            var top = windowHeight / 2 - height / 2;
            var left = windowWidth / 2 - width / 2;

            $("div.msgBox").css({ "top": top, "left": left });
        });
    }

    function hide() {
        if (!isShown) {
            return;
        }
        options.beforeClose();
        $("div.msgBox").animate({ opacity: 0, "top": top - 50, "left": left }, 200);
        $("div.msgBoxBackGround").fadeOut(300);
        setTimeout(function () { $("div.msgBox,div.msgBoxBackGround").remove(); }, 300);
        setTimeout(options.afterClose, 300);
        isShown = false;
    }

    function getDocHeight() {
        var D = document;
        return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight));
    }

    function getFocus() {
        $("div.msgBox").fadeOut(200).fadeIn(200);
    }

    $("input.msgButton").click(function (e) {
        e.preventDefault();
        var value = $(this).val();
        if (options.type != "prompt") {
            options.success(value);
        }
        else {
            var inputValues = [];
            $("div.msgInput input").each(function (index, domEle) {
                var name = $(this).attr("name");
                var value = $(this).val();
                var type = $(this).attr("type");
                if (type == "checkbox" || type == "radio") {
                    inputValues.push({ name: name, value: value,checked: $(this).attr("checked")});
                }
                else {
                    inputValues.push({ name: name, value: value });
                }
            });
            options.success(value,inputValues);
        }
        hide();
    });

    $("div.msgBoxBackGround").click(function (e) {
        if (!options.showButtons || options.autoClose) {
            hide();
        }
        else {
            getFocus();
        }
    });
};

//function msg (content, title, type) {
//    msg({content:content,title:title,type:type});
//}
/*
jQuery.msgBox插件
版权所有2011,Halilİbrahim Kalyoncu
*/
jQuery.msgBox=msg;
功能消息(选项){
var isShown=假;
var typeOfValue=期权类型;
var默认值={
内容:(typeOfValue==“字符串”?选项:“消息”),
标题:“警告”,
键入:“警报”,
自动关闭:错误,
超时:0,
显示按钮:正确,
按钮:[{值:“确定”}],
输入:[{type:“text”,name:“userName”,header:“User name”},{type:“password”,name:“password”,header:“password”}],
成功:函数(结果){},
beforeShow:function(){},
afterShow:function(){},
beforeClose:函数(){},
afterClose:函数(){},
不透明度:0.1
};
选项=typeOfValue==“字符串”?默认值:选项;
if(options.type!=null){
开关(选项.类型){
案例“警报”:
options.title=options.title==null?“警告”:options.title;
打破
案例“信息”:
options.title=options.title==null?“信息”:options.title;
打破
案例“错误”:
options.title=options.title==null?“错误”:options.title;
打破
案例“确认”:
options.title=options.title==null?“确认”:options.title;
options.buttons=options.buttons==null?[{value:“Yes”},{value:“No”},{value:“Cancel”}]:options.buttons;
打破
案例“提示”:
options.title=options.title==null?“登录”:options.title;
options.buttons=options.buttons==null?[{value:“Login”},{value:“Cancel”}]:options.buttons;
打破
违约:
image=“alert.png”;
}
}
options.timeOut=options.timeOut==null?(options.content==null?500:options.content.length*70):options.timeOut;
选项=$.extend(默认值,选项);
如果(选项。自动关闭){
setTimeout(隐藏,选项.timeOut);
}
var image=“”;
开关(选项.类型){
案例“警报”:
image=“alert.png”;
打破
案例“信息”:
image=“info.png”;
打破
案例“错误”:
image=“error.png”;
打破
案例“确认”:
image=“confirm.png”;
打破
违约:
image=“alert.png”;
}
var按钮=”;
$(选项.按钮)。每个(功能(索引,按钮){
按钮+=“”;
});
var输入=”;
$(选项.输入)。每个(函数(索引,输入){
var type=input.type;
如果(类型==“复选框”| |类型==“收音机”){
输入+=“”+
"" +
“”+input.header+“”+
"";
}
否则{
输入+=“”+
“”+input.header+“”+
"" +
"";
}
});
var divBackGround=“”
var divTitle=“”+options.title+”;
var divContainer=“”+options.content+”

”; var divButtons=“”+按钮+”; var=“”+输入+”; 如果($(“div.msgBox”).length==0){ 如果(options.type==“提示”){ $(“正文”).append(divBackGround+“”+divTitle+“”+divContainer+(options.showButtons?divButtons+“”):“”+“”); $(“div.msgBoxImage”).remove(); $(“div.msgBoxButtons”).css({“文本对齐”:“中间”,“边距顶部”:“5px”}); $(“div.msgBoxContent”).css({“宽度”:“100%”,“高度”:“100%”); $(“div.msgBoxContent”).html; } 否则{ $(“正文”).append(divBackGround+“”+divTitle+“”+divContainer+(options.showButtons?divButtons+“”):“”+“”); } } 否则{ 如果(options.type==“提示”){ $(“div.msgBox”).html(divTitle+“”+divContainer+(options.showButtons?divButtons+“”):“”); $(“div.msgBoxImage”).remove(); $(“div.msgBoxContent”).css(“宽度”、“100%”); $(“div.msgBoxContent”).html; } 否则{ $(“div.msgBox”).html(divTitle+“”+divContainer+(options.showButtons?divButtons+“”):“”); } } 变量宽度=$(“div.msgBox”).width(); 变量高度=$(“div.msgBox”).height(); var windowHeight=$(window.height(); var windowWidth=$(window.width(); var top=窗高/2-高度/2; var left=窗宽/2-宽度/2; show(); 函数show(){ 如果(isShown){ 返回; } css({opacity:0,top:top-50,left:left}); $($div.msgBoxBackGround”).css({opacity:options.opacity}); options.beforeShow(); $(“div.msgBoxBackGround”).css({“width”:$(document.width(),“height”:getDocHeight()}); $(“div.msgBox,div.msgBoxBackGround”).fadeIn(0); $(“div.msgBox”).animate({opacity:1,“top”:top,“left”:left},200); 设置超时(options.afterShow,200); isShown=真; $(窗口)。绑定(“调整大小”,函数(e){ 变量宽度=$(“div.msgBox”).width(); 变量高度=$(“div.msgBox”).height(); var windowHeight=$(window.height(); var windowWidth=$(window.width(); var top=窗高/2-高度/2; var left=窗宽/2-宽度/2; $(“div.msgBox”).css({“top”:top,“left”:left}); }); } 函数hide(){ 如果(!isShown){ 返回;