$this.append($(contentBoxObj));  这个this是指哪个jquery对象?  $(this)

解决方案 »

  1.   


    是我的$("#dialog")对象那应该这么写吧 $(this)
      

  2.   

    这个东西只要把iframe放到div中设置 iframe的高度和宽度自己会居中的。给你个例子 
    function closeDialog(){

    if ($("#div_cmmbDialog").get(0) != null) {$("#div_cmmbDialog").dialog("close");}
    }function closeConfirmDialog(){
    if ($("#div_confirmDialog").get(0) != null) {$("#div_confirmDialog").dialog("close");}

    }(function($) {//弹出窗口:可包含子窗口
    $.showDialog = function(_title, _url, _width, _height){
    var iwidth = 600;
    var iheight = 400;
    if (_width) iwidth = _width;
    if (_height) iheight = _height; if ($("#div_cmmbDialog").get(0) == null) {
            $("body").append("<div id=\"div_cmmbDialog\"    title=\""+_title+"\"></div>");
            $("#div_cmmbDialog").append("<iframe id='frm_cmmbDialog' name='frm_cmmbDialog' width='100%' height='100%'"
                    +" marginwidth='0' marginheight='0' scrolling='auto' frameborder='0' "
                    +" border='0' framespacing='2' noresize='noresize' vspale='0'></iframe>");        $("#div_cmmbDialog:ui-dialog").dialog("destroy");
            $("#div_cmmbDialog").dialog({
                autoOpen: false,
                modal: true,
                width: iwidth,
                height: iheight
            });
        }
      

  3.   

        if (_url.indexOf("?")>0){
         _url += "&"+Math.floor(Math.random() * 1000);
        }
        else{
         _url += "?"+Math.floor(Math.random() * 1000);
        }
        $("#ui-dialog-title-div_cmmbDialog").html(_title);
    $("#frm_cmmbDialog").attr("src",_url);
    $("#div_cmmbDialog").attr("title",_title);
    $("#div_cmmbDialog").dialog("open");
    }
      

  4.   


    我和你使用的情况不一样,我是通过load()获取iframe src="content.html"的内容的宽和高,因为load()方法是异步的,搞的现在还没load完的时候我的dialog就已经居中了,到load完后在直接撑开了dialog的尺寸,这样就没有居中。有没有方法可以让load方法异步加载完成后再去执行下面的内容?
      

  5.   


    是我的$("#dialog")对象那应该这么写吧 $(this)是的,代码没贴全,差这个var $this = $(this);
      

  6.   

    $this.css({
        "display": "none",
        "left": ($(window).width() / 2 - iframeBoxWidth / 2) + "px",
        "top": ($(window).height() / 2 - iframeBoxHeight / 2) + "px",
        "z-index": "10000"
    });
    扔到load方法里面去