zoukankan      html  css  js  c++  java
  • javascript样式切换,图片切换,随机背景

    http://www.cssrain.cn/article.asp?id=560

    <link id="rain" href="http://bbs.blueidea.com/forumdata/cache/style_2.css" rel="stylesheet" type="text/css">
    </HEAD>
    <script>
    function changeStyle(url){
    cacheobj=document.getElementById("rain");
    cacheobj.href=url
    }
    </script>
    <BODY>
    <a href="javascript:changeStyle('http://www.redflystudios.com/css_style.css');">样式1</a>
    <a href="javascript:changeStyle('http://www.wz-qs.com/css.css');">样式2</a>
    <a href="javascript:changeStyle('http://bbs.blueidea.com/forumdata/cache/style_2.css');">默认样式</a>




    图片切换:

    程序代码 程序代码
    <select name="selectface" onchange="cssrain(options[selectedIndex].value);">

    <script>
    for(i=1;i<12;i++)
    {
    document.write("<option value=http://www.makewing.com/lanren/emotions/07/"+i+".gif>头像"+i+"</option>");
    }
    </script>
    </select>

    <img id="face" src="http://www.makewing.com/lanren/emotions/07/1.gif">

    <SCRIPT LANGUAGE="JavaScript">
    function cssrain(obj)
    {
    document.getElementById("face").src=obj;
    }
    </SCRIPT>



    随即背景:

    程序代码 程序代码
    <Script Language="JavaScript">
       image = new Array(2); //定义image为图片数量的数组
       image [0] = 'http://www.cssrain.cn/skins/tim/logo-jq.gif' //背景图象的路径
       image [1] = 'http://www.cssrain.cn/demo/JQuery+API/logo-json.gif'
       image [2] = 'http://www.cssrain.cn/skins/tim/isll_t.gif'
       number = Math.floor(Math.random() * image.length);
       document.write("<BODY BACKGROUND="+image[number]+">");
    </Script>



    网页最后修改时间:

    程序代码 程序代码
    <script language="LiveScript">
    <!-- Hiding
      today = new Date()
      document.write("现 在 时 间 是: ",today.getHours(),":",today.getMinutes())
      document.write("<br>今 天 日 期 为: ", today.getMonth()+1,"/",today.getDate(),"/",today.getYear());
    // end hiding contents -->
    </script>

    <html>
    <body>
    This is a simple HTML- page.
    <br>
    Last changes:
      <script language="LiveScript">
      <!--  hide script from old browsers
        document.write(document.lastModified)
      // end hiding contents -->
      </script>
    </body>
    </html>



    获取上传文件的大小:

    程序代码 程序代码
    <html>  
    <input type="file" name="uploadfiles" onchange="ShowSize(this.value)">  <span id="rain"></span>
    <script language="JavaScript">  
    <!--  
    /**
    * obj 创建文件对象
    * FilesObj 得到文件所上传的文件对像
    * mySize 被上传文件的大小
    */
    function ShowSize(files)  
    {  
       var obj,FilesObj ;  
       obj = new ActiveXObject("Scripting.FileSystemObject");  
       FilesObj = obj.GetFile(files);

       var mySize = FilesObj .size/(1024*1024);
       document.getElementById("rain").innerHTML=mySize+" M ";
    }  
    //-->  
    </script>  
    </html>
  • 相关阅读:
    “王者对战”之 MySQL 8 vs PostgreSQL 10
    PostgreSQL 进程结构
    Linux core dump 诊断进程奔溃退出
    linux下core dump--转载
    2.4 等比数列
    2.3 等差数列的前n项和
    2.2 等差数列
    1.1.1 三角形正弦定理
    调整颜色
    去括号法则
  • 原文地址:https://www.cnblogs.com/luluping/p/1440073.html
Copyright © 2011-2022 走看看