解决方法 - Ueditor编辑器中的表情图片地址为HTTP协议导致HTTPS站含有非HTTPS资源...

    选择打赏方式

前言:

 

呃,今天博客把EMLOG自带的编辑器换成了百度的Ueditor后发现表情插入的图片都为HTTP协议,然后博客就被浏览器识别为不安全了(HTTPS协议不能含有非HTTPS协议资源 否则会被浏览器识别为不安全)。。

这里说一下解决方法。


解决方法:

把 "admin/ueditor/dialogs/emotion/emotion.js" 文件 修改为以下内容保存就大功告成了,如果你发现插入的还是HTTP协议的图片就清除一下浏览器的缓存就可以了。

  1. window.onload = function () {
  2. editor.setOpt({
  3. emotionLocalization:false
  4. });
  5.  
  6. emotion.SmileyPath = editor.options.emotionLocalization === true ? 'images/' : "http://img.baidu.com/hi/";
  7. emotion.SmileyBox = createTabList( emotion.tabNum );
  8. emotion.tabExist = createArr( emotion.tabNum );
  9.  
  10. initImgName();
  11. initEvtHandler( "tabHeads" );
  12. };
  13.  
  14. function initImgName() {
  15. for ( var pro in emotion.SmilmgName ) {
  16. var tempName = emotion.SmilmgName[pro],
  17. tempBox = emotion.SmileyBox[pro],
  18. tempStr = "";
  19.  
  20. if ( tempBox.length ) return;
  21. for ( var i = 1; i <= tempName[1]; i++ ) {
  22. tempStr = tempName[0];
  23. if ( i < 10 ) tempStr = tempStr + '0';
  24. tempStr = tempStr + i + '.gif';
  25. tempBox.push( tempStr );
  26. }
  27. }
  28. }
  29.  
  30. function initEvtHandler( conId ) {
  31. var tabHeads = $G( conId );
  32. for ( var i = 0, j = 0; i < tabHeads.childNodes.length; i++ ) {
  33. var tabObj = tabHeads.childNodes[i];
  34. if ( tabObj.nodeType == 1 ) {
  35. domUtils.on( tabObj, "click", (function ( index ) {
  36. return function () {
  37. switchTab( index );
  38. };
  39. })( j ) );
  40. j++;
  41. }
  42. }
  43. switchTab( 0 );
  44. $G( "tabIconReview" ).style.display = 'none';
  45. }
  46.  
  47. function InsertSmiley( url, evt ) {
  48. url=url.replace('http','https');
  49. var obj = {
  50. src:editor.options.emotionLocalization ? editor.options.UEDITOR_HOME_URL + "dialogs/emotion/" + url : url
  51. };
  52. obj._src = obj.src;
  53. editor.execCommand( 'insertimage', obj );
  54. if ( !evt.ctrlKey ) {
  55. dialog.popup.hide();
  56. }
  57. }
  58.  
  59. function switchTab( index ) {
  60.  
  61. autoHeight( index );
  62. if ( emotion.tabExist[index] == 0 ) {
  63. emotion.tabExist[index] = 1;
  64. createTab( 'tab' + index );
  65. }
  66. //获取呈现元素句柄数组
  67. var tabHeads = $G( "tabHeads" ).getElementsByTagName( "span" ),
  68. tabBodys = $G( "tabBodys" ).getElementsByTagName( "div" ),
  69. i = 0, L = tabHeads.length;
  70. //隐藏所有呈现元素
  71. for ( ; i < L; i++ ) {
  72. tabHeads[i].className = "";
  73. tabBodys[i].style.display = "none";
  74. }
  75. //显示对应呈现元素
  76. tabHeads[index].className = "focus";
  77. tabBodys[index].style.display = "block";
  78. }
  79.  
  80. function autoHeight( index ) {
  81. var iframe = dialog.getDom( "iframe" ),
  82. parent = iframe.parentNode.parentNode;
  83. switch ( index ) {
  84. case 0:
  85. iframe.style.height = "380px";
  86. parent.style.height = "392px";
  87. break;
  88. case 1:
  89. iframe.style.height = "220px";
  90. parent.style.height = "232px";
  91. break;
  92. case 2:
  93. iframe.style.height = "260px";
  94. parent.style.height = "272px";
  95. break;
  96. case 3:
  97. iframe.style.height = "300px";
  98. parent.style.height = "312px";
  99. break;
  100. case 4:
  101. iframe.style.height = "140px";
  102. parent.style.height = "152px";
  103. break;
  104. case 5:
  105. iframe.style.height = "260px";
  106. parent.style.height = "272px";
  107. break;
  108. case 6:
  109. iframe.style.height = "230px";
  110. parent.style.height = "242px";
  111. break;
  112. default:
  113.  
  114. }
  115. }
  116.  
  117.  
  118. function createTab( tabName ) {
  119. var faceVersion = "?v=1.1", //版本号
  120. tab = $G( tabName ), //获取将要生成的Div句柄
  121. imagePath = emotion.SmileyPath + emotion.imageFolders[tabName], //获取显示表情和预览表情的路径
  122. positionLine = 11 / 2, //中间数
  123. iWidth = iHeight = 35, //图片长宽
  124. iColWidth = 3, //表格剩余空间的显示比例
  125. tableCss = emotion.imageCss[tabName],
  126. cssOffset = emotion.imageCssOffset[tabName],
  127. textHTML = ['<table class="smileytable">'],
  128. i = 0, imgNum = emotion.SmileyBox[tabName].length, imgColNum = 11, faceImage,
  129. sUrl, realUrl, posflag, offset, infor;
  130. var st;
  131. var str;
  132. st = emotion.SmileyPath;
  133. str = st.replace ('http','https');
  134. for ( ; i < imgNum; ) {
  135. textHTML.push( '<tr>' );
  136. for ( var j = 0; j < imgColNum; j++, i++ ) {
  137. faceImage = emotion.SmileyBox[tabName][i];
  138. if ( faceImage ) {
  139. sUrl = imagePath + faceImage + faceVersion;
  140. realUrl = imagePath + faceImage;
  141. posflag = j < positionLine ? 0 : 1;
  142. offset = cssOffset * i * (-1) - 1;
  143. infor = emotion.SmileyInfor[tabName][i];
  144. textHTML.push( '<td class="' + tableCss + '" border="1" width="' + iColWidth + '%" style="border-collapse:collapse;" align="center" bgcolor="transparent" onclick="InsertSmiley(\'' + realUrl.replace( /'/g, "\\'" ) + '\',event)" onmouseover="over(this,\'' + sUrl + '\',\'' + posflag + '\')" onmouseout="out(this)">' );
  145. textHTML.push( '<span>' );
  146. textHTML.push( '<img style="background-position:left ' + offset + 'px;" title="' + infor + '" src="' + str + (editor.options.emotionLocalization ? '0.gif" width="' : 'default/0.gif" width="') + iWidth + '" height="' + iHeight + '"></img>' );
  147. textHTML.push( '</span>' );
  148. } else {
  149. textHTML.push( '<td width="' + iColWidth + '%" bgcolor="#FFFFFF">' );
  150. }
  151. textHTML.push( '</td>' );
  152. }
  153. textHTML.push( '</tr>' );
  154. }
  155. textHTML.push( '</table>' );
  156. textHTML = textHTML.join( "" );
  157. tab.innerHTML = textHTML;
  158. }
  159.  
  160. function over( td, srcPath, posFlag ) {
  161. td.style.backgroundColor = "#ACCD3C";
  162. $G( 'faceReview' ).style.backgroundImage = "url(" + srcPath + ")";
  163. if ( posFlag == 1 ) $G( "tabIconReview" ).className = "show";
  164. $G( "tabIconReview" ).style.display = 'block';
  165. }
  166.  
  167. function out( td ) {
  168. td.style.backgroundColor = "transparent";
  169. var tabIconRevew = $G( "tabIconReview" );
  170. tabIconRevew.className = "";
  171. tabIconRevew.style.display = 'none';
  172. }
  173.  
  174. function createTabList( tabNum ) {
  175. var obj = {};
  176. for ( var i = 0; i < tabNum; i++ ) {
  177. obj["tab" + i] = [];
  178. }
  179. return obj;
  180. }
  181.  
  182. function createArr( tabNum ) {
  183. var arr = [];
  184. for ( var i = 0; i < tabNum; i++ ) {
  185. arr[i] = 0;
  186. }
  187. return arr;
  188. }






版权声明:若无特殊注明,本文皆为《 Macro 》原创,转载请保留文章出处。
本文链接:解决方法 - Ueditor编辑器中的表情图片地址为HTTP协议导致HTTPS站含有非HTTPS资源被浏览器识别为不安全 https://blog.julym.com/original/175.html
百度收录情况: 百度已收录,详情
正文到此结束

热门推荐

发表吐槽

你肿么看?

你还可以输入 250 / 250 个字

嘻嘻 大笑 可怜 吃惊 害羞 调皮 鄙视 示爱 大哭 开心 偷笑 嘘 奸笑 委屈 抱抱 愤怒 思考 日了狗 胜利 不高兴 阴险 乖 酷 滑稽

评论信息框

吃奶的力气提交吐槽中...


既然没有吐槽,那就赶紧抢沙发吧!