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

推荐订阅源

P
Proofpoint News Feed
WordPress大学
WordPress大学
Help Net Security
Help Net Security
Jina AI
Jina AI
Security Latest
Security Latest
Y
Y Combinator Blog
Project Zero
Project Zero
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
Know Your Adversary
Know Your Adversary
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
NISL@THU
NISL@THU
Cisco Talos Blog
Cisco Talos Blog
博客园 - 司徒正美
MyScale Blog
MyScale Blog
Cyberwarzone
Cyberwarzone
D
Docker
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
C
CERT Recently Published Vulnerability Notes
B
Blog
L
LangChain Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
SecWiki News
SecWiki News
The Hacker News
The Hacker News
C
Check Point Blog
L
Lohrmann on Cybersecurity
V2EX - 技术
V2EX - 技术
S
Securelist
T
Threat Research - Cisco Blogs
Stack Overflow Blog
Stack Overflow Blog
TaoSecurity Blog
TaoSecurity Blog
云风的 BLOG
云风的 BLOG
Latest news
Latest news
人人都是产品经理
人人都是产品经理
L
LINUX DO - 最新话题
Application and Cybersecurity Blog
Application and Cybersecurity Blog
The Register - Security
The Register - Security
Webroot Blog
Webroot Blog
Simon Willison's Weblog
Simon Willison's Weblog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Security Blog
Microsoft Security Blog
AWS News Blog
AWS News Blog
C
Cybersecurity and Infrastructure Security Agency CISA
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
小众软件
小众软件
T
Tailwind CSS Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
宝玉的分享
宝玉的分享
O
OpenAI News

博客园 - 搞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  希望伸缩后的实际图片显示高度

哈哈 绝对不失真