$(".mainlist").append("<iframe id='dialogFrom' src='" + url + "' style='width:100%; height:100%;' marginwidth='0' marginheight='0' frameborder='0' scrolling='auto' onload='this.height=this.contentWindow.document.body.scrollHeight+5;this.width=this.contentWindow.document.body.scrollWidth+5;'/>");
    
tipsWindown(title, "id:dialog", $("#dialogFrom").width(), $("#dialogFrom").height(), "true", "", "true", "dialog");
在用Jquery进行操作时我先用append,但是执行到tipsWindown后append的值还没有被执行我获取不到width 和height的信息。我应该怎么办啊 !jquerydialogiframe

解决方案 »

  1.   

    iframe的宽度高度反正是100%,你获取$(this).width()不行吗?
      

  2.   

    写错了,
    $(".mainlist").width()
      

  3.   

    我是在onload='this.height=this.contentWindow.document.body.scrollHeight+5;this.width=this.contentWindow.document.body.scrollWidth+5;' 重新取得高度的!
      

  4.   

    这么说吧!我想要iframe加载页的高度和宽度!我能用什么方法获取!
      

  5.   

    这样写试下$('#dialogFrom').load(function(){
    tipsWindown(title, "id:dialog", $("#dialogFrom").width(), $("#dialogFrom").height(), "true", "", "true", "dialog");
    });
      

  6.   

    现在一个函数里面,先执行append,再取其值
      

  7.   

    不行!onload='this.height=this.contentWindow.document.body.scrollHeight+5;this.width=this.contentWindow.document.body.scrollWidth+5;' 还没有执行后面的函数就执行了啊!
      

  8.   


    iframe里面的onload写在$(xx).load(xx)里面$('#dialogFrom').load(function(){
    this.height=this.contentWindow.document.body.scrollHeight+5;
    this.width=this.contentWindow.document.body.scrollWidth+5;
    tipsWindown(title, "id:dialog", this.width, this.height, "true", "", "true", "dialog");
    });
      

  9.   


    试过了不行!取不到值!我就是想做个Jquery弹出层的自适应而已啊!鼓捣两天了!郁闷
      

  10.   

    最后的解决方案是在body中设置相关属性,然后获取,并且需要在ifram onlond事件中获取!