preview.jsp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <%@ page language="java" contentType="text/html; charset=utf-8"
  2. pageEncoding="utf-8"%>
  3. <%
  4. String path = request.getContextPath();
  5. String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
  6. %>
  7. <!DOCTYPE html>
  8. <html>
  9. <head>
  10. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  11. <script type="text/javascript" src="<%=basePath %>resource/ext/ext-all.js"></script>
  12. <style>
  13. #nc_content p {
  14. font-size: 14px;
  15. color: #626262;
  16. text-indent: 2em;
  17. margin: 32px 0;
  18. }
  19. </style>
  20. </head>
  21. <body>
  22. <script type="text/javascript">
  23. var basePath = (function() {
  24. var fullPath = window.document.location.href;
  25. var path = window.document.location.pathname;
  26. var subpos = fullPath.indexOf('//');
  27. var subpath = subpos > -1 ? fullPath.substring(0, subpos + 2) : '';
  28. if (subpos > -1)
  29. fullPath = fullPath.substring(subpos + 2);
  30. var pos = fullPath.indexOf(path), sname = path.substring(0, path.substr(1).indexOf('/') + 1);
  31. sname = (['/jsps','/workfloweditor','/resource','/system','/process','/demo','/exam','/oa','/opensys','/mobile'].indexOf(sname) > -1 ? '/' : sname);
  32. return subpath + fullPath.substring(0, pos) + sname + (sname == '/' ? '' : '/');
  33. })();
  34. var id = '${param.id}';
  35. var opener = window.opener;
  36. if(opener){
  37. var div = document.createElement("div");
  38. var val = opener.Ext.getCmp(id).getValue();
  39. var html = '<div style="padding:10px 0px;height:100%;position: absolute;left: 50%;top:-8px;transform: translate(-50%,0);"><div id = "' + id + '" style="width:900px;height:100%;border:1px solid #000;overflow:auto;">'+val+'</div></div>'
  40. div.innerHTML = html;
  41. document.body.appendChild(div);
  42. }else if (parseInt(id)!='NaN'){
  43. Ext.Ajax.request({
  44. url: basePath + 'public/getNewsHtml.action',
  45. params: {
  46. id: id
  47. },
  48. callback: function(opt, s, r) {
  49. var res = Ext.decode(r.responseText);
  50. if(res.exceptionInfo) {
  51. showError(res.exceptionInfo);
  52. } else if (res.success){
  53. var div = document.createElement("div");
  54. div.innerHTML = '<div id = "' + id + '">'+res.newshtml+'</div>';
  55. document.body.appendChild(div);
  56. }
  57. }
  58. });
  59. }
  60. </script>
  61. </body>
  62. </html>