Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/420.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/70.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 获取图像';s';雷亚尔';IE中的宽度和高度_Javascript_Html_Image_Internet Explorer_Shadowbox - Fatal编程技术网

Javascript 获取图像';s';雷亚尔';IE中的宽度和高度

Javascript 获取图像';s';雷亚尔';IE中的宽度和高度,javascript,html,image,internet-explorer,shadowbox,Javascript,Html,Image,Internet Explorer,Shadowbox,我目前正在建立一个网站,并使用Shadowbox JS插件来显示图像 因为我们通过JSP提供图像(而不是直接链接到图像文件),Shadowbox似乎无法动态确定它们的宽度和高度,所以只能在屏幕大小的重叠中打开图像 可以使用“rel”手动将宽度和高度传递给shadowbox插件,因此我使用以下代码解决了FF/Chrome/Safari的问题: $('#pic1img').attr("src")).load(function() { picWidth = this.wi

我目前正在建立一个网站,并使用Shadowbox JS插件来显示图像

因为我们通过JSP提供图像(而不是直接链接到图像文件),Shadowbox似乎无法动态确定它们的宽度和高度,所以只能在屏幕大小的重叠中打开图像

可以使用“rel”手动将宽度和高度传递给shadowbox插件,因此我使用以下代码解决了FF/Chrome/Safari的问题:

$('#pic1img').attr("src")).load(function() {
            picWidth    = this.width;
            picHeight   = this.height;
    });

 $(window).load(
            function() {
                var w = $("#pic1img").width();
                var h = $("#pic1img").height();
                if( picWidth < w ){ picWidth = w; }
                if( picHeight < h ){ picHeight = h; }
                $('#pic1').attr('rel', 'shadowbox[pics];height=' + picHeight + ';width=' + picWidth);
            }
 );
$('pic1img').attr(“src”).load(函数(){
picWidth=此宽度;
picHeight=这个高度;
});
$(窗口)。加载(
函数(){
var w=$(“#pic1img”).width();
var h=$(“#pic1img”).height();
如果(picWidth