不错呦!smile@林凯西,确保“准备文件”中的几个文件都有安装,S...您好,看了您这篇帖子觉得很有帮助。但是有个问题想请...我的修改过了怎么还被恶意注册呢 @jjjjiiii 用PJ快9年了,主要是A...PJ3啊,貌似很少有人用PJ了,现在不是WP就是z...@332347365,我当时接入时错误码没有-10...楼主,ChkValue值应为-103是什么意思呢?...大哥 你最近能看到我发的信息,请跟我联系,我有个制...
JS按比例缩放图片
编辑:dnawo 日期:2007-10-26
复制内容到剪贴板
程序代码

//来自:新浪网-新闻中心(http://news.sina.com.cn/)
//调用:<img src="" onload="javascript:DrawImage(this)">
function DrawImage(ImgD){
var image=new Image();
var iwidth = 120; //默认宽
var iheight = 120; //默认高
image.src=ImgD.src;
if(image.width>0 && image.height>0){
if(image.width/image.height>= iwidth/iheight){
if(image.width>iwidth){
ImgD.width=iwidth;
ImgD.height=(image.height*iwidth)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}else{
if(image.height>iheight){
ImgD.height=iheight;
ImgD.width=(image.width*iheight)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
}
}
//调用:<img src="" onload="javascript:DrawImage(this)">
function DrawImage(ImgD){
var image=new Image();
var iwidth = 120; //默认宽
var iheight = 120; //默认高
image.src=ImgD.src;
if(image.width>0 && image.height>0){
if(image.width/image.height>= iwidth/iheight){
if(image.width>iwidth){
ImgD.width=iwidth;
ImgD.height=(image.height*iwidth)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}else{
if(image.height>iheight){
ImgD.height=iheight;
ImgD.width=(image.width*iheight)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
}
}
复制内容到剪贴板
程序代码

//来自:QZone(http://270250392.qzone.qq.com/)
function adjustSize(obj,w,h,openWindows){
obj.onload=null;
if(w<=0||h<=0)return ;
var w0=obj.width,h0=obj.height,r=false;
if(w0<1){
var i=new Image();
i.src=obj.src;
w0=i.width;
h0=i.height;
}
if((w0/h0)>(w/h)){
if(w0>w){
setTimeout(function (o,i){ return function(){o.style.width=i}}(obj,w),0);
w0=w;
r=true;
}
}else {
if(h0>h){
setTimeout(function (o,i){return function (){o.style.height=i}}(obj,h),0);
h0=h;
r=true;
}
}
if(openWindows&&r){
obj.style.cursor="pointer";
obj.title="点击预览原图";
obj.onclick=function (){window.open(obj.src);}
}
if(!!obj.transImg&&Browser.isIE&&!Browser.isIE7){
obj.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,src="+obj.src+",sizingmethod=scale);";
obj.style.height=h0;
obj.style.width=w0;
obj.src="/ac/qzone_v4/b.gif";
}
}
function adjustSize(obj,w,h,openWindows){
obj.onload=null;
if(w<=0||h<=0)return ;
var w0=obj.width,h0=obj.height,r=false;
if(w0<1){
var i=new Image();
i.src=obj.src;
w0=i.width;
h0=i.height;
}
if((w0/h0)>(w/h)){
if(w0>w){
setTimeout(function (o,i){ return function(){o.style.width=i}}(obj,w),0);
w0=w;
r=true;
}
}else {
if(h0>h){
setTimeout(function (o,i){return function (){o.style.height=i}}(obj,h),0);
h0=h;
r=true;
}
}
if(openWindows&&r){
obj.style.cursor="pointer";
obj.title="点击预览原图";
obj.onclick=function (){window.open(obj.src);}
}
if(!!obj.transImg&&Browser.isIE&&!Browser.isIE7){
obj.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,src="+obj.src+",sizingmethod=scale);";
obj.style.height=h0;
obj.style.width=w0;
obj.src="/ac/qzone_v4/b.gif";
}
}
评论: 0 | 引用: 0 | 查看次数: 4016
发表评论
请登录后再发表评论!