问题描述
i有一个大问题...我正在使用一个jscript来调整我所有的照片
popUp ...在主html中我有很多小照片并点击它们
它们在popUp中打开并调整到相同图片的大图。
现在,它工作正常,有时当我点击一个小小的它没有
调整大小...
这是代码:
main。 html
< a href ="#" onclick =" javascript :
window.open(''/ html / popUp.html'',''Malo'',''toolbar = 0,location = 0,directori es = 0,st
atus = 0,menubar = 0,scrollbars = 0,resizable = 0''); return false;">
< IMG src =" /images/thumbs/Malo.jpg" border =" 0">
< / a>
popUp.html
< script language =" JavaScript">
var pic = new Image();
var url =''/ images / pics /''+ name +''。 JPG ''; // name =''Malo''来自main.html
pic.src = url;
函数调整大小(){
窗口。 location = url;
var wid = pic.width + 30; //有时pic.width = 0和wid = 30和
有时候还可以
var hei = pic.height + 50; //有时pic.height = 0和hei = 50和
有时候还可以
alert(" wid =" + wid +" \\\
" + hei =" + hei);
window.resizeTo(wid,hei);
}
< / script>
< / head>
< body onload =" javascript :resizing();" >
< / body>
i不知道hapens ...也许有些图片没有时间加载所以
pic.width和height是0但是当我关闭popUp并再次打开它为
相同的图片时,它的调整大小...我的意思是,调整错误的图片第二次
调整好......
如果有人知道我做错了什么帮助请!!!
非常感谢你!
Hi,
i have a big problem...i''m using one jscript for resizing of all of my pics
in popUp...in main html i''m having many little pics and clicking on them
they open in popUp and resize to larger version of the same pic.
now, it works fine and sometimes when i click on little one it doesn''t
resize well...
this is the code:
main.html
<a href="#" onclick="javascript:
window.open(''/html/popUp.html'',''Malo'',''toolbar=0,location=0,directori es=0,st
atus=0,menubar=0,scrollbars=0,resizable=0'');return false;">
<IMG src="/images/thumbs/Malo.jpg" border="0">
</a>
popUp.html
<script language="JavaScript">
var pic = new Image();
var url=''/images/pics/''+name+''.jpg''; // name=''Malo'' from main.html
pic.src = url;
function resizing(){
window.location=url;
var wid=pic.width+30; // sometimes pic.width=0 and wid=30 and
sometimes is OK
var hei=pic.height+50; // sometimes pic.height=0 and hei=50 and
sometimes is OK
alert("wid="+wid+"\n"+"hei="+hei);
window.resizeTo(wid, hei);
}
</script>
</head>
<body onload="javascript: resizing();">
</body>
i don''t know what hapens...maybe some pic doesn''t have time to load so
pic.width and height is 0 but when i close popUp and open it again for the
same pic, it resizes well...i mean, the pic that resizes wrong second time
resizes well...
If someone know what i''m doing wrong help please!!!
Thank You very much!
推荐答案
抱歉,我不会评论你的剧本 - 用
调整图片大小的想法Javascript对我来说似乎很奇怪。你应该制作两个不同的
图像文件,一个用于缩略图,一个用于大视图。调整大小
图片在屏幕上看起来总是很糟糕,因为像素是内插的,甚至是b
外推。
并且:如果你增加尺寸你就不会没有足够的数据,如果你把它变成了b / b
你传输了太多数据。
-
Markus
Sorry I don''t comment your script - the idea of resizing images with
Javascript just seems very strange to me. You should make two different
image files, one for the thumbnail and one for the big view. Resized
pictures always look bad on screen, as pixels are interpolated or even
extrapolated.
And: If you increase the size you don''t have enough data, and if you make it
smaller you transfer too much data.
--
Markus
这篇关于调整问题...紧急!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!