demo1.htm 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>优道在线屏幕截图控件演示 — Base64方式上传</title>
  5. <meta http-equiv="Content-Language" content="zh-cn" />
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  8. <style type="text/css">
  9. label{font-size:12px;}
  10. h3{float:right;margin:4px 30px;line-height:40px;}
  11. a{color:#3079ED}
  12. a:hover{color:red}
  13. #logInfo{background-color:#eee;border:1px solid #999;height:30px;line-height:30px;font-size:12px;padding:2px 20px;}
  14. #snapImg{border:1px solid #666;margin-top:10px;height:650px;overflow:auto; text-align:center;}
  15. #btnCapture{border:1px solid #3079ED;background-color:#498AF4;color:#ffffff;line-height:40px;font-weight:bold; text-decoration:none; text-align:center;padding:5px 20px;}
  16. #btnCapture:hover{background-color:#3B80EE}
  17. </style>
  18. <script type="text/javascript" src="UdCapture.js?2.0.1"></script>
  19. <script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script>
  20. <script type="text/javascript">
  21. window.onload = function () {
  22. //其中"btnCapture"为截图按钮的ID
  23. var udCapture = new UdCapture("btnCapture", {
  24. FileName:"SnapScreen.jpg",
  25. OnClick: function () {
  26. udCapture.AutoMinimize = document.getElementById("autoMin").checked;
  27. if (document.getElementById("captureScreen").checked)
  28. udCapture.CaptureScreen();
  29. else
  30. udCapture.StartCapture();
  31. },
  32. OnStartSetup: function (setupFile) {
  33. f_log("正在进行安装,安装完成后请<a href=''>刷新当前页面</a>!");
  34. },
  35. OnBeforeCapture: function () {
  36. f_log("开始截图");
  37. },
  38. OnCaptureCanceled: function () {
  39. f_log("已取消截图");
  40. },
  41. OnCaptureCompleted: function (file, imgData) {
  42. if (imgData == "") {
  43. var msg = "截图太大不支持上传"
  44. f_log(msg);
  45. // alert(msg);
  46. return;
  47. }
  48. f_log("<img src=\"icons/Loading.gif\" style=\"vertical-align:text-bottom\" />&nbsp;正在上传截图...");
  49. //调用jQuery异步上传base64格式,请求的文件可以根据需要换为其它语言
  50. $.post("ashx/SaveBase64.ashx", { FileName: file, ImageData: imgData }, function (json) {
  51. f_log("图片上传完成.");
  52. document.getElementById("snapImg").innerHTML = "<img src=\"" + json.filepath + "?" + Math.random() + "\">"
  53. });
  54. }
  55. });
  56. }
  57. //显示事件消息
  58. function f_log(str) {
  59. document.getElementById("logInfo").innerHTML = str;
  60. }
  61. </script>
  62. </head>
  63. <body>
  64. <div id="ctlDiv">
  65. <a id="btnCapture" href="javascript:;">屏幕截图</a>
  66. <input type="checkbox" id="autoMin" value="1" /><label for="autoMin">自动最小化当前窗口</label>
  67. <input type="checkbox" id="captureScreen" value="1" /><label for="captureScreen">直接捕捉当前屏幕</label>
  68. <h3><img alt="" src="icons/UdCapture.gif" style="vertical-align:baseline" />&nbsp;优道在线屏幕截图控件演示1</h3>
  69. <div id="logInfo">请点击上面的按钮开始进行屏幕截图</div>
  70. </div>
  71. <div id="snapImg"></div>
  72. </body>
  73. </html>