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

推荐订阅源

I
InfoQ
C
CERT Recently Published Vulnerability Notes
The Last Watchdog
The Last Watchdog
P
Proofpoint News Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
GbyAI
GbyAI
T
Tenable Blog
博客园 - 三生石上(FineUI控件)
P
Privacy & Cybersecurity Law Blog
Simon Willison's Weblog
Simon Willison's Weblog
Jina AI
Jina AI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tor Project blog
博客园_首页
F
Fortinet All Blogs
博客园 - Franky
Latest news
Latest news
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
U
Unit 42
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hugging Face - Blog
Hugging Face - Blog
D
Docker
Project Zero
Project Zero
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
MongoDB | Blog
MongoDB | Blog
F
Full Disclosure
D
DataBreaches.Net
Google DeepMind News
Google DeepMind News
Cisco Talos Blog
Cisco Talos Blog
Y
Y Combinator Blog
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
H
Help Net Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
月光博客
月光博客
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
Schneier on Security
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed
PCI Perspectives
PCI Perspectives
Cloudbric
Cloudbric
V
Visual Studio Blog
Recorded Future
Recorded Future
人人都是产品经理
人人都是产品经理

博客园 - 搞IT的狐狸

ASP.Net动态使用CSS - 搞IT的狐狸 - 博客园 SqlDataReader或DATATABLE DATASET 到EXCEL [转载]ROW_NUM实现分页 (转载)ASP.NET本地化 VS2005 TreeView 的 CheckBox 被点击时的引发页面回发事件 (转发) ASP.NET 2.0,C#----利用GridView控件导出其他文件(导出Excel,导出Word文件) 什么是SHTML 如何使用IFRAM JS来刷新UpdatePanel 随即验证码实现(根据韩现龙代码修改) [北京]招聘 网站设计师 我这半个月的代码总结(小技巧,小代码)之二 用Themes实现网站换肤 将数据控件(如GridView)的内容转化成Excel格式文件 ASP.NET新手实用技巧!(C#) 学历不高!写给自己!自勉! 一张笑死我又让我辛酸的图片!开发人员的辛酸! 服务器刚开,凑个沙发!.NET几点你应该知道的细节! 求动态绑定控件ID的值的方法!着急!
我这半个月的代码总结(小技巧,小代码)之一
搞IT的狐狸 · 2007-09-14 · via 博客园 - 搞IT的狐狸

一:通用  检查HTTP的函数:

实现功能:

         一:检查用户输入的网站连接代码(如果以非http://开头则自动加上http头)
       二:无论用户输入的路径如何都只显示主站点的URL(比如http://blog.sina.com.cn/myblog/u/3554345.htm  只显示http://blog.sina.com.cn/

    public string checkHttp(String http)  //检查HTTP
    {

      
        if (!(http == "原创") && !(http == "投票") && !(http == ""))      //如果非---为原创,投票,或者空
        {
            if (http.IndexOf("http://") > -1)                         //判断是否包括HTTP头
            {
                if (http.Substring(7, http.Length - 7).IndexOf("/") > -1)   //包括头情况下删除URL住站后的“/”
                {
                    http = http.Substring(0, http.Substring(7).IndexOf("/") + 8);  
                }
            }
            else
            {

                if (http.IndexOf("/") > -1)   //没HTTP头
                {
                    http = (http.Substring(0, http.IndexOf("/") + 1)).Insert(0, "http://");
                }
            }
        }
        else
        {
            return http;
        }
        return http;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function chang_img(img,maxwidth,maxheight){
 var image=new Image();
 image=img;
 if(image.width/image.height>=maxwidth/maxheight)
 {
  if(image.width>maxwidth)
  {
   img.width=maxwidth;
   img.height=maxwidth*image.height/maxheight;
  }
  else
  {
   img.width=image.width;
   img.height=image.height;
  } 
 }
 else
 {
  if(image.height>maxheight)
  {
   img.width=maxheight*image.width/image.height;
   img.height=image.height;
  }
  else
  {
   img.width=image.width;
   img.height=image.height;
  }
 }
}
</script>
</head>

<body>

<img src="1.jpg" onload="chang_img(this,50,50)" />
</body>
</html>
解决问题:正常我们在不确定图片大小的情况下,要求最后确定大小格式图片输出的时候要采取伸缩图的形式,
                 如果硬性规定图片显示大小的话会造成两种错误效果:一 图片被伸缩后 严重变形失真,二:图片只看到了一部分小区域

上面的代码经过计算 长和高 进行判断伸缩比例和结构

img变量为被引用的图片“对象”,可以通过this传递给本变量
maxwidth  希望伸缩后的实际图片显示宽度
maxheight  希望伸缩后的实际图片显示高度

哈哈 绝对不失真