• 比较精妙的一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>
  • 相关阅读:
    Java实现 LeetCode 537 复数乘法(关于数学唯一的水题)
    Java实现 LeetCode 537 复数乘法(关于数学唯一的水题)
    Java实现 LeetCode 535 TinyURL 的加密与解密(位运算加密)
    Java实现 LeetCode 535 TinyURL 的加密与解密(位运算加密)
    如何在 Linux 中统计一个进程的线程数
    linux下查看线程数的几种方法
    深入理解linux系统下proc文件系统内容
    嵌入式 如何定位死循环或高CPU使用率(linux)
    Linux 下查看线程信息
    Linux netstat命令详解
  • 原文地址:https://www.cnblogs.com/sxlfybb/p/1225298.html
Copyright © 2020-2023  润新知