免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2421 | 回复: 0
打印 上一主题 下一主题

WEB 图片查阅器 HTML版 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-08-24 10:11 |只看该作者 |倒序浏览

  1. 转载地址: [url]http://www.hoojar.com/view-lore.php?lid=52723[/url]  WEB 图片查阅器
  2. WEB 图片查阅器
  3. 功能: 根据图片大小自动缩放展示,在弹出的窗体中按屏幕的大小自动算出要显示的位置,显示窗体的位置通常是居中显示的,
  4. 些控件相常有用,用来查看WEB方式的图片最佳.

  5. 使用方法:只需要在你的网页中加载<script language="javascript" src="zoom.js"></script>,并在要设置的查阅的图片处
  6. 设置:onclick="ShowPic('', this)" onload="if(this.width>screen.width-100)this.width=screen.width-100;" onmousewheel="zoomimg(this)"

  7. 例:<img src="http://www.hoojar.com/images/logo.gif" border="0"  onclick="ShowPic('', this)" onload="if(this.width>screen.width-100)this.width=screen.width-100;" onmousewheel="zoomimg(this)" />
  8. 查看此图片只须点击原来的图片就可弹出WEB图片查阅器,在IE用户使用鼠标轮子还能达到缩放的最佳效果.

  9. 若您还不明白,您看[url]http://www.hoojar.com/[/url]网站上的例子即可.

  10. <!-- filename look-pic.html -->
  11. <html>
  12. <head>
  13. <title>View photos</title>
  14. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  15. <script language="javascript" src="./zoom.js"></script>
  16. </head>
  17. <body leftmargin="0" topmargin="0" onload="InitSize()" ondblclick="window.close()" onclick="InitSize()">
  18. <table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
  19.         <tr align="center">
  20.                 <td>
  21.                 <script language="javascript">
  22.                 <!--
  23.                 var url = self.location.href;
  24.                 url = CleftValue(url);
  25.                 document.write("<img src=\"" + url + "\" id=\"pic\" onload=\"if(this.width>screen.width)this.width=screen.width;if(this.height>screen.height)this.height=screen.height;\" onmousewheel=\"zoomimg(this)\">");
  26.                 //-->
  27.                 </script>
  28.                 </td>
  29.         </tr>
  30. </table>
  31. </body>
  32. </html>

  33. <!-- filename zoom.js -->
  34. <!--
  35. ///////////////////////////////////////////////////////////////////////////////
  36. //
  37. // 张树林 - 慧佳工作室
  38. //
  39. // Module Name:     zoom.js
  40. // Abstract:        用于WEB图片查阅器
  41. // Version:         1.0
  42. // Date                    2007-06-11
  43. // Author:          woods·zhang
  44. // Email:           [email]hoojar@163.com[/email]
  45. // MSN:             [email]hoojar@hotmail.com[/email]
  46. // Copyright 2001-2006, Hoojar studio All Rights Reserved
  47. //
  48. // 版权 2001-2006,慧佳工作室所有版权保护

  49. //The software for free software, allowing use, copy,
  50. //modify and distribute the software and files. Any
  51. //use of this software must place a copy of all the
  52. //above copyright notice. By the software Huijia studio
  53. //maintenance, if you have any queries please contact us.
  54. //Thank you.
  55. //
  56. //此软件为自由软件,允许使用、拷贝、修改、分发本软件及其文档。
  57. //任何使用此软件的地方都得出现以上版权通告所有副本。此软件由
  58. //慧佳工作室维护,如果您有什么疑问请与我们联系。谢谢使用。
  59. //
  60. ///////////////////////////////////////////////////////////////////////////////
  61. var NeedWidht = 400;
  62. var NeedHeight = 300;
  63. var scrwi = screen.width;
  64. var scrhe = screen.height;
  65. var woods = "";

  66. function ShowPic(url, ob)
  67. {
  68.         if (scrwi <= 800)
  69.         {
  70.           woods = "fullscreen=yes,resizable=no";
  71.         }
  72.         else
  73.         {
  74.                 var left = (scrwi - NeedWidht)/2;
  75.                 var top = (scrhe - NeedHeight)/2 ;
  76.                 woods = "left="+ left +",top=" + top + ",width=" + NeedWidht + ",height=" + NeedHeight + ",fullscreen=no,status=no,resizable=yes,scrollbars=no,dialog=yes,modal=yes" ;
  77.         }
  78.         var url = url + "/js/look-pic.html?" + ob.src.replace("s_", "");
  79.         var dwin = window.open(url, "lookpic", woods);
  80.         dwin.focus();
  81. }

  82. function zoomimg(pic)//放大与缩小图片
  83. {
  84.   var zoom=parseInt(pic.style.zoom,10)||100;
  85.   zoom+=event.wheelDelta/12;
  86.   if (zoom>0) pic.style.zoom=zoom+'%';
  87.   return false;
  88. }

  89. function ResizePic()
  90. {
  91.          var pic = document.getElementById("pic");
  92.          pic.style.width = document.body.clientWidth;
  93.          pic.style.height = document.body.clientHeight;
  94.          pic.style.zoom = "100%";
  95. }

  96. function InitSize()
  97. {
  98.         var pic = document.getElementById("pic");
  99.         pic.style.zoom = "100%";

  100.         NeedWidht = pic.width;
  101.         NeedHeight = pic.height;
  102.         var left = (scrwi - NeedWidht) / 2;
  103.         var top = (scrhe - NeedHeight) / 2 ;
  104.         window.moveTo(left,top);
  105.         window.resizeTo(pic.width + 6, pic.height + 50);
  106.         pic.style.zoom = "100%";
  107. }

  108. function CleftValue(url)//分解url?后的值
  109. {
  110.                 url = url.substring(url.indexOf("?") + 1, url.length);
  111.                 return url;
  112. }
  113. //-->

  114. 转载地址: [url]http://www.hoojar.com/view-lore.php?lid=52723[/url]  WEB 图片查阅器

复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP