zoukankan      html  css  js  c++  java
  • 比较精妙的一JS语句

    转自:http://topic.csdn.net/u/20080606/10/0fcfca71-a23c-4026-8372-a9e2b19f0ef1.html?seed=116085589

    我现在就是写不出这样的代码,转一下,作为目标。

    把原代码以HTML代码形式贴出的时候,博客园竟然贴不出。我汗死,直接贴在这儿了。

    <
    html>
    <head>
    <title>hz-gb-2312 转码工具</title>
    <HTA:APPLICATION
    APPLICATIONNAME="CabMKR"
    Icon
    ="http://ialvin.cn/favicon.ico"
    ID
    ="oHTA"
    CAPTION
    ="yes"
    CONTEXTMENU
    ="no"
    INNERBORDER
    ="no"
    BORDER
    ="thin"
    BORDERSTYLE
    ="normal"
    MAXIMIZEBUTTON
    ="no"
    MINIMIZEBUTTON
    ="yes"
    SHOWINTASKBAR
    ="yes"
    INGLEINSTANCE
    ="no"
    SYSMENU
    ="yes"
    VERSION
    ="1.0"
    windowstate
    ="normal"
    SCROLL
    ="no"/>

    <style type="text/css">
    html,body
    { font-size:12px; margin:0; overflow:hidden; }
    fieldset
    { padding:5px; margin:5px; text-align:center; }
    </style>

    <script type="text/JScript">
    window.resizeTo(
    480, 310);
    window.moveTo((screen.width
    -480)/2, (screen.height-310)/2);
    var $ = function(id) { return document.getElementById(id); };
    String.prototype.saveTo
    = function(path, cSet) {
    var out = new ActiveXObject("ADODB.Stream");
    with (out) { Type=2; Open(); CharSet=cSet||"GBK"; Position=0; WriteText=this; SaveToFile(path,2); Close(); }
    delete out;
    };
    String.loadFrom
    = function(path, cSet) {
    var ins = new ActiveXObject("ADODB.Stream");
    with (ins) { Type=2; Mode=3; Open(); CharSet=cSet||"GBK"; Position=0; LoadFromFile(path); }
    var s = ins.ReadText();
    ins.Close();
    delete ins;
    return s;
    };

    function converEncoding(str, wcs, rcs) {
    var s = new ActiveXObject("ADODB.Stream");
    with (s) { Mode=3; Type=2; Open(); CharSet=wcs; WriteText=str; Position=0; CharSet=rcs; str=ReadText(-1); Close(); }
    delete s; return str;
    }
    function encode(s) { return converEncoding(s, "hz-gb-2312", "gbk"); }
    function decode(s) { return converEncoding(s, "gbk", "hz-gb-2312"); }

    function doDecode() {
    //var code = String.loadFrom($('txt').value);
    $("txt").value = decode($('txt').value);
    // code.saveTo("ok.txt");
    // alert("转换编码后的内容已保存到 ok.txt");
    }
    </script>
    </head>
    <body>
    <fieldset>
    <legend>内容</legend>
    <textarea id="txt" style="100%" rows="14"><meta content="~{11>)E`@hV0R5Q'T:UPIzW(R5~}" name="description"></textarea>
    <input type="button" onclick="JScript:doDecode();" value=" 转 码 " />
    </fieldset>
    </body>
    </html>
  • 相关阅读:
    php 延迟静态绑定: static关键字
    python分片
    用逗号分隔数字,神奇
    ubuntu 屏幕截图
    js 获取随机数
    netty : NioEventLoopGroup 源码分析
    LinkedList 源码分析
    面向对象
    JS
    网页
  • 原文地址:https://www.cnblogs.com/sxlfybb/p/1225298.html
Copyright © 2011-2022 走看看