dynamic.html 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>模板动态化</title>
  6. <script type="text/ecmascript" src="${ctx}/assets/lib/jquery/1.9.1/jquery.js"></script>
  7. <script type="text/javascript" src="${ctx}/assets/lib/layer/3.0.3/layer.js"></script>
  8. <script type="text/javascript">
  9. jQuery.fn.outerHTML = function(s) {
  10. return s ? this.before(s).remove() : jQuery("<p>").append(this.eq(0).clone()).html();
  11. };
  12. var dialogIndex;
  13. function showDialog(dialogID,dialogTitle,dialogURL,dialogWidth,dialogHeight){
  14. dialogIndex=layer.open({
  15. type: 2,
  16. title: dialogTitle,
  17. shade: 0.8,
  18. area: [dialogWidth+'px', dialogHeight+'px'],
  19. content: '${ctx}'+dialogURL //iframe的url
  20. });
  21. }
  22. function closeDialog(index){
  23. layer.close(index);
  24. }
  25. $(function(){
  26. $("#bc").click(function(){
  27. var _workbench=$("#workbench").contents();
  28. //alert(_workbench.find("html").outerHTML());
  29. _workbench.find(".dynamicembed").remove();
  30. _workbench.find("div[id^='yShade']").remove();
  31. //myconsole.log(_workbench.find("html").outerHTML());
  32. var temp=_workbench.find("html").outerHTML();
  33. //var temp=_workbench.find("html");
  34. var doctype="<!DOCTYPE html >";
  35. $.post("${ctx}/myconsole/template/save",{"tempID":"${tempID}","tempContent":doctype+temp},function(data){
  36. layer.msg(data);
  37. })
  38. })
  39. })
  40. </script>
  41. </head>
  42. <body>
  43. <div style="text-align:center;margin-bottom:10px;"><button id="bc" style="background:#f4a542;border-radius:5px;color:#fff;border:none;padding:8px 18px;font-size:13px;">保存</button></div>
  44. <iframe id="workbench" name="workbench" src="${ctx}/myconsole/dynamic/workbench?tempID=${tempID}" width=100% height=900></iframe>
  45. </body>
  46. </html>