tomcat实现session保持案例
2015-11-01 01:07
435 查看
<script language=Javascript> var proMaxHeight = 150; var proMaxWidth = 110; function proDownImage(ImgD){ var image=new Image(); image.src=ImgD.src; if(image.width>0 && image.height>0){ var rate = (proMaxWidth/image.width < proMaxHeight/image.height)?proMaxWidth/image.width:proMaxHeight/image.height; if(rate <= 1){ ImgD.width = image.width*rate; ImgD.height =image.height*rate; } else { ImgD.width = image.width; ImgD.height =image.height; } } } </script>
百度的javascript还好啦。所以收录下来。如果懂这个的话,一看就懂了。呵呵。。。
不过还是介绍一下用法。。。。。
<img src="http://www.baidu.com/images/logo.gif" />
上面是一般的HTML里面用的插入图片的一段。。。很简单。但是当插入的图片是网友上传的图片,对尺寸/比例不确定的时候。我们需要的就是这个js了。。。这段代码可以根据网友上传的图片,进行比例缩放。这样不会导致很多商品展示都出现的。图片尺寸都固定死了的情况。。。。用法很简单,把上面的这段javascript放到<head></head>之间,然后把<img src="http://www.baidu.com/images/logo.gif" /> 改成<img src="http://www.baidu.com/images/logo.gif" onload=proDownImage(this); />这样。就可以了。意思就是在图片load装载的时候,调用proDownImage函数对this(即图片本身)对象进行设置。就可以了。很简单,但很实用。
相关文章推荐
- Tomcat中JVM内存溢出及合理配置
- tomcat的基本搭建(一)
- Windows系统安装配置Apache+JK+tomcat负载均衡环境
- Nginx Tomcat Session 丢失 改变
- apache 与 tomcat 服务器的三种连接配置方式
- 手机访问不了Eclipse中Tomcat服务?
- tomcat 中的 bootstrap 与 catalina
- Tomcat中对于post方法提交的表单采用的默认编码
- Centos 6.7 Tomcat基本安装测试
- Intellij idea13配置tomcat,并实现一个简单的servlet
- Centos 6.7 Tomcat Session集群
- 启动tomcat8提示内存泄漏问题解决
- Tomcat7 设置最大连接数
- Tomcat环境配置
- 在eclipse中配置tomcat,不用经常重启Tomcat
- 2015第44周六tomcat集群了解
- tomcat7配置
- 收集Tomcat异常日志并发送邮件
- 内存溢出之Tomcat内存配置
- Eclipse安装tomcat插件详解