Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iframe维度没有“auto”属性,如何通过jQuery模拟?_Jquery_Html_Iframe - Fatal编程技术网

iframe维度没有“auto”属性,如何通过jQuery模拟?

iframe维度没有“auto”属性,如何通过jQuery模拟?,jquery,html,iframe,Jquery,Html,Iframe,我正在操纵一个iframe,使它等于它包含的图像的尺寸。我快到了。问题是,我绝对可以得到img的高度。但是图像的宽度是通过“自动”属性推导出来的。但是我不能对iframe做同样的事情,它只接受像素和百分比 $(this).contents().find('img').load(function(){ //get the computed styles of the img via the computedstyle.js plugin var myCSS = $(this).ge

我正在操纵一个iframe,使它等于它包含的图像的尺寸。我快到了。问题是,我绝对可以得到img的高度。但是图像的宽度是通过“自动”属性推导出来的。但是我不能对iframe做同样的事情,它只接受像素和百分比

$(this).contents().find('img').load(function(){
    //get the computed styles of the img via the computedstyle.js plugin
    var myCSS = $(this).getCSS();
    //grab the height and width of the newly loaded image
    var myY = myCSS.height.slice(0, - 2);
        if(myY>heightRef){
            $(this).closest(".photoset_row").css({height: heightRef});
            $(this).closest(".photoset_row").css({width: 'auto'});
            myFrame.attr('height',(heightRef-0));
            myFrame.attr('width',________); //auto is not accepted
        }else{
            var myX = myCSS.width.slice(0, - 2);
            $(this).closest(".photoset_row").css({height: heightRef});
            $(this).closest(".photoset_row").css({width: myX});
            myFrame.attr('height',myY);
            myFrame.attr('width',myX);
        }
...
试图获得图像的计算宽度是一个很滑的斜坡,它可能已经加载,也可能没有加载


我怎么能做到

在这里开箱思考,但是更新共享的公共Cookie呢?如果两个域没有什么不同,那就是。我想知道是否有比轮询Ajax调用更好的方法。我必须问一下,为什么有一个只显示图像的iframe?为什么要使用iframe呢?为什么不能将图像动态插入到自己的网页中,而不必处理iframe.hai RGBK。你是否只是想将图像插入iframe,使iframe的大小随着图像的大小而增加。。??很抱歉我这么问,因为我没听清你的问题。