tmp.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>iframe</title>
  6. <style>
  7. html,body{
  8. margin: 0;
  9. height: 100%;
  10. font: 13px/1.555 "Trebuchet MS", sans-serif;
  11. }
  12. a{
  13. color: #888;
  14. font-weight: bold;
  15. text-decoration: none;
  16. border-bottom: 1px solid #888;
  17. }
  18. .main-box {
  19. color:#252525;
  20. padding: 3px 5px;
  21. text-align: justify;
  22. }
  23. .main-box p{margin: 0 0 14px;}
  24. .main-box .cerr{
  25. color: #f00000;
  26. border-bottom-color: #f00000;
  27. }
  28. </style>
  29. </head>
  30. <body>
  31. <div id="content" class="main-box"></div>
  32. <iframe src="" frameborder="0" id="spelltext" name="spelltext" style="display:none; width: 100%" ></iframe>
  33. <iframe src="" frameborder="0" id="loadsuggestfirst" name="loadsuggestfirst" style="display:none; width: 100%" ></iframe>
  34. <iframe src="" frameborder="0" id="loadspellsuggestall" name="loadspellsuggestall" style="display:none; width: 100%" ></iframe>
  35. <iframe src="" frameborder="0" id="loadOptionsForm" name="loadOptionsForm" style="display:none; width: 100%" ></iframe>
  36. <script>
  37. (function(window) {
  38. // Constructor Manager PostMessage
  39. var ManagerPostMessage = function() {
  40. var _init = function(handler) {
  41. if (document.addEventListener) {
  42. window.addEventListener('message', handler, false);
  43. } else {
  44. window.attachEvent("onmessage", handler);
  45. };
  46. };
  47. var _sendCmd = function(o) {
  48. var str,
  49. type = Object.prototype.toString,
  50. fn = o.fn || null,
  51. id = o.id || '',
  52. target = o.target || window,
  53. message = o.message || { 'id': id };
  54. if (type.call(o.message) == "[object Object]") {
  55. (o.message['id']) ? o.message['id'] : o.message['id'] = id;
  56. message = o.message;
  57. };
  58. str = JSON.stringify(message, fn);
  59. target.postMessage(str, '*');
  60. };
  61. return {
  62. init: _init,
  63. send: _sendCmd
  64. };
  65. };
  66. var manageMessageTmp = new ManagerPostMessage;
  67. var appString = (function(){
  68. var spell = parent.CKEDITOR.config.wsc.DefaultParams.scriptPath;
  69. var serverUrl = parent.CKEDITOR.config.wsc.DefaultParams.serviceHost;
  70. return serverUrl + spell;
  71. })();
  72. function loadScript(src, callback) {
  73. var scriptTag = document.createElement("script");
  74. scriptTag.type = "text/javascript";
  75. callback ? callback : callback = function() {};
  76. if(scriptTag.readyState) {
  77. //IE
  78. scriptTag.onreadystatechange = function() {
  79. if (scriptTag.readyState == "loaded" ||
  80. scriptTag.readyState == "complete") {
  81. scriptTag.onreadystatechange = null;
  82. setTimeout(function(){scriptTag.parentNode.removeChild(scriptTag)},1)
  83. callback();
  84. }
  85. };
  86. }else{
  87. //Others
  88. scriptTag.onload = function() {
  89. setTimeout(function(){scriptTag.parentNode.removeChild(scriptTag)},1);
  90. callback();
  91. };
  92. };
  93. scriptTag.src = src;
  94. document.getElementsByTagName("head")[0].appendChild(scriptTag);
  95. };
  96. window.onload = function(){
  97. loadScript(appString, function(){
  98. manageMessageTmp.send({
  99. 'id': 'iframeOnload',
  100. 'target': window.parent
  101. });
  102. });
  103. }
  104. })(this);
  105. </script>
  106. </body>
  107. </html>