惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
博客园 - 司徒正美
C
Check Point Blog
G
Google Developers Blog
The GitHub Blog
The GitHub Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
有赞技术团队
有赞技术团队
P
Proofpoint News Feed
IT之家
IT之家
B
Blog
博客园_首页
量子位
MongoDB | Blog
MongoDB | Blog
博客园 - Franky
J
Java Code Geeks
H
Help Net Security
A
About on SuperTechFans
Apple Machine Learning Research
Apple Machine Learning Research
Jina AI
Jina AI
D
DataBreaches.Net
Y
Y Combinator Blog
大猫的无限游戏
大猫的无限游戏
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News

博客园 - 刹那间我存在

一个可以放wordpress博客的PHP国外免费空间速度非常不错 重写alert,使用模态窗口强化alert。 - 刹那间我存在 - 博客园 利用 ASP.NET 的Timer 来实现的访问统计,感觉比较适合高访问量的网站 JavaScript 使用for(…in…)实现反射机制 给moz添加ie方法和属性,让firefox像IE一样编程 - 刹那间我存在 - 博客园 [原] 用 javascript 给你的博客增加运行代码功能 [原]ASP.NET 下生成的条形码。 同时支持三种事件模型 ASP调用.Net编写的动态库 - 刹那间我存在 - 博客园 整个表单元素禁用``` shtml精简教程 更改数据库所有者 BitComet超级优化设置 很酷的TOOLTip JS函数收藏 今天得到了两个 Google Analytics 的邀请 CustomValidator 控件 千万数量级分页存储过程(带效果演示) 推荐一下免费的1G网络硬盘,非常另类
网页中图片大小自动调整三种方法 - 刹那间我存在 - 博客园
刹那间我存在 · 2006-06-09 · via 博客园 - 刹那间我存在

1.鼠标滚动图片大小调整

<body>
<script LANGUAGE="JAVASCRIPT">
function bbimg(o){
   var zoom=parseInt(o.style.zoom, 10)||100;

zoom+=event.wheelDelta/12;

if (zoom>0)

 o.style.zoom=zoom+'%';

   return false;
}
</script> 
<img src="123.jpg" onload="javascript:if(this.width>screen.width-screen.width/2) this.style.width=screen.width-screen.width/2" onmousewheel="return bbimg(this)" > 
</body>

2.图片自动缩小到固定大小

<body onload="DrawImage(theimg)">
<script language="JavaScript">
<!--
//图片按比例缩放
var flag=false;
function DrawImage(ImgD){
  var image=new Image();
  var iwidth = 320;  //定义允许图片宽度
  var iheight = 180;  //定义允许图片高度
  image.src=ImgD.src;
  if(image.width>0 && image.height>0){
   flag=true;
   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;
    }
    ImgD.alt=image.width+"×"+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;
    }
    ImgD.alt=image.width+"×"+image.height;
    }
   }

//-->
</script>
<img src="123.jpg" width="1024" height="768" name="theimg">
</body> 
3.滚轮图片缩放的代码<script language="javascript">
var count = 10;
function resizeimg(oImage)

count = Counting(count);
Resize(oImage,count);
return false;
}
function Counting(newzoom){ 
if (event.wheelDelta >= 120)
newzoom++;
else if (event.wheelDelta <= -120)
newzoom--;
if (newzoom<2) newzoom=2; ////只允许缩小到20%
if (newzoom>50) newzoom=50; ////只允许放大到500%
return newzoom; 
}
function Resize(oImage,newzoom){ 
oImage.style.zoom = newzoom + '0%'; 
count=newzoom;
}
</script>

然后在<img src="">中加入
onDblClick="return Resize(this,10);return false;" 
onmousewheel="return resizeimg(this)"