basedata.html 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <style>
  9. html, body, div, span, applet, object, iframe,
  10. h1, h2, h3, h4, h5, h6, p, blockquote, pre,
  11. a, abbr, acronym, address, big, cite, code,
  12. del, dfn, em, img, ins, kbd, q, s, samp,
  13. small, strike, strong, sub, sup, tt, var,
  14. b, u, i, center,
  15. dl, dt, dd, ol, ul, li,
  16. fieldset, form, label, legend,
  17. table, caption, tbody, tfoot, thead, tr, th, td,
  18. article, aside, canvas, details, embed,
  19. figure, figcaption, footer, header, hgroup,
  20. menu, nav, output, ruby, section, summary,
  21. time, mark, audio, video {
  22. margin: 0;
  23. padding: 0;
  24. border: 0;
  25. font-size: 100%;
  26. font: inherit;
  27. vertical-align: baseline;
  28. box-sizing: border-box;
  29. font-family: Source Han Sans CN;
  30. }
  31. .page{
  32. padding: 15px;
  33. font-size: 14px;
  34. line-height: 16px;
  35. color:#333;
  36. }
  37. </style>
  38. </head>
  39. <body>
  40. <div class="page">
  41. {$content}
  42. </div>
  43. </body>
  44. </html>
  45. <script src="/assets/js/jquery-3.1.1.min.js"></script>
  46. <script>
  47. function replaceDetail(){
  48. var details = $('.page').html();
  49. //newContent仅是details替换后内容;
  50. let newContent = details.replace(/<img[^>]*>/gi, function (match, capture) { //去除三标签
  51. match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
  52. match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
  53. match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
  54. return match;
  55. });
  56. newContent = newContent.replace(/<br[^>]*\/>/gi, '');
  57. newContent = newContent.replace(/<img/gi, '<img style="max-width:100%;height:auto;display:block;margin:0 auto;"');
  58. $('.page').html('');
  59. $('.page').html(newContent);
  60. }
  61. replaceDetail();
  62. </script>