易截截图软件、单文件、免安装、纯绿色、仅160KB

JavaScript,等比例缩放图片的函数

<script language="JavaScript">
<!--
//图片按比例缩放
var flag=false;
function DrawImage(ImgD,iwidth,iheight){
    //参数(图片,允许的宽度,允许的高度)
    var image=new Image();
    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


相关文档:

Javascript 代码着色工具 SyntaxHighlighter

1.首先下载SyntaxHighlighter.
2.解压到SyntaxHighlighter目录中.
 
3.建立HTML文件:
 
<pre name="code" class="Ruby">
 ...Ruby代码...
</pre>
 
可以应用在pre和textarea两种HTML标签内,name为code,class为要着色的语言,现在支持C, C#, CSS, Delphi, Java, JScript, Php, Pyth ......

CSS+JavaScript实现层级显示隐藏

/***************************by
garcon1986********************************/
感谢CSDN的shan1119 帮我解决Javascript部分的错误。
<mce:script language="JavaScript"><!--
function toggle(id,id2,id3) {
var state = document.getElementById(id).style.display;
if (state == 'block') {
......

结合canvas进行javascript性能测试

在对程序进行性能测试时需要考虑到不同规模以及不同算法的效率的不同
下面的网页是一个对排序算法的性能测试,规模就是数组的长度,而测试的两个函数分别是手动实现的快速排序算法和javascript内置的排序函数。
<!DOCTYPE window PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1- ......

JavaScript正则表达式

//校验是否全由数字组成 
function isDigit(s) 

var patrn=/^[0-9]{1,20}$/; 
if (!patrn.exec(s)) return false 
return true 

//校验登录名:只能输入5-20个以字母开头、可带数字、“_”、“.”的字串 
function isRegisterUserName(s)
{
v ......

JavaScript实现水平选项卡效果

首先在body中加入以下HTML内容:
<div id="panel">
 <div id="top">
        <ul id="menu">
            <li id="1">Home</li>
 &nbs ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号