2016年4月26日 星期二

C# 使用 Stopwatch 查看code花費時間

System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
 sw.Start();
//code...
sw.Stop();
Response.Write("spend:" + sw.ElapsedMilliseconds + "ms" + "<br />");

2016年4月19日 星期二

ckeditor 取得textarea欄位值

var str=CKEDITOR.instances.textname.getData();
alert(str);

textname為textarea欄位id或是name

2016年4月18日 星期一

Highcharts 好用的圖表套件

官方網站:http://www.highcharts.com/
官方說明文件:http://api.highcharts.com/highcharts#global
中文化說明文件:http://www.hcharts.cn/api/#yAxis.ceiling

可先至官方網站看想要用的樣式,點選進去後可以直接在線上觀看demo

2016年4月15日 星期五

2016年4月14日 星期四

filesaver.js 將html table的資料匯出成Excel

參考網址:http://kyleap.blogspot.tw/2015/08/filesaverjs-html-tableexcel.html

另外補充若需要將匯出文件(word)改成橫向,可增加  html-docx-js  這個js

參考網址1:https://github.com/evidenceprime/html-docx-js
參考網址2:http://evidenceprime.github.io/html-docx-js/


作法如下:
在<html>標籤增加一個id,之後js寫法如下

<script type="text/javascript">
    function Output()
    {
        var strFile = "檔案名稱.doc";
        var content = $('#id').html();
        var converted = htmlDocx.asBlob(content, { orientation: "landscape" });//此處參數請參考官網說明
        saveAs(converted, strFile);//輸出    
    }
</script>

2016年4月10日 星期日

javascript window.print(); 只印網頁的一部份

<style media=print type="text/css">
#noprint{visibility:hidden}
</style>

<div class="row pt20″ id="printdiv">
<img src"" />
</div>

//這樣在id="printdiv" 範圍內的才會顯示在列印畫面
<script>
window.print();
</script>

Jquery Checkbox 全選與全取消

<script>
        $(document).ready(function () {
            $("#checkdcIscfm").click(function () {
                if ($("#checkdcIscfm").prop("checked")) {//如果全選按鈕有被選擇的話(被選擇是true)
                    $("input[class=’cdcIscfm’]").prop("checked", true); //把所有的核取方框的property都變成勾選
                     //$("input[name=’cdcIscfm’]").prop("checked", true); //把所有的核取方框的property都變成勾選
                } else {
                    $("input[class=’cdcIscfm’]").prop("checked", false); //把所有的核取方框的property都取消勾選
                }
            })
        })
        
</script>