Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/468.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/1/php/292.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
Javascript 如何使用检测到的浏览器缩放级别保持Iframe';s宽度和高度相同_Javascript_Php_Css_Html - Fatal编程技术网

Javascript 如何使用检测到的浏览器缩放级别保持Iframe';s宽度和高度相同

Javascript 如何使用检测到的浏览器缩放级别保持Iframe';s宽度和高度相同,javascript,php,css,html,Javascript,Php,Css,Html,我试图保持iframe的大小不变,无论用户在浏览器中放大了多少。我让它通过根据缩放级别调整宽度来处理图像。但似乎无法让它与iframe一起工作。真正重新调整iframe大小的唯一方法是使用“变换比例”。我使用这个插件来计算缩放 javascript /*get the value of the image width and height*/ var iframeDimensions = document.getElementById('mobile-iframe'); var iwidth

我试图保持iframe的大小不变,无论用户在浏览器中放大了多少。我让它通过根据缩放级别调整宽度来处理图像。但似乎无法让它与iframe一起工作。真正重新调整iframe大小的唯一方法是使用“变换比例”。我使用这个插件来计算缩放

javascript

/*get the value of the image width and height*/

var iframeDimensions = document.getElementById('mobile-iframe');
var iwidth = iframeDimensions.clientWidth;

$(window).resize(function() {
    var device = detectZoom.device();
    console.log(device);
    newWidth = iwidth / device;
    console.log(newWidth+'px');
    $(iframeDimensions).attr('width', newWidth);
    //I would get the iframe to resize  useing this line of code but what is the best way of using this with scale ? 
    $('iframe').css('-webkit-transform', 'scale(' + (document.body.offsetWidth / newWidth) + ')');
});
HTML

<iframe id="mobile-iframe" src="https://www.google.com/logos/doodles/2013/maria-callas-90th-birthday-6111044824989696-hp.jpg" width="534" height="205"  frameborder="0"  ></iframe>  
<img id="mobile-iframe" src="https://www.google.com/logos/doodles/2013/maria-callas-90th-birthday-6111044824989696-hp.jpg" width="534" alt=""/>

我阅读了该线程,并能够解决部分问题,但可能存在重复。但我现在遇到的问题有点不同,因为计算缩放级别不是我的问题@卢法马