Rich Text (YUI) Editor Broken on IE11

こ雲淡風輕ζ 提交于 2019-12-04 07:24:56
kinglomei

For IE changed its User-Agent, YUI(2.9) need a surgery.

  1. Modify yahoo-dom-event.js: Find this: YAHOO.env.parseUA, then at last add something that tell YAHOO.env.ua now is undering IE 11. like this:

     if (g.ie == 0 && c.indexOf('Trident') != -1){
         g.ie = 11;
     }
    
  2. Modify editor.js: Find the _setInitialContent function, and after the if-branch that includes "BackCompat", add this:

    this.browser = YAHOO.env.parseUA();
    

    then just in the following if-branch (if (this.browser.ie || this.browser.webkit || this.browser.opera || (navigator.userAgent.indexOf('Firefox/1.5') != -1))): add this:

     if (this.browser.ie == 11) {
         this.browser.ie = 0;
     }
    

Hope Works, Good Luck!

kinglomei's solution works, but you might have to modify it slightly to get it to work for you. In YUI, that parseUA function can be defined in many different places depending on how you set up your website; ours happens to define it in the yahoo.js file, but it is often defined in utilies, yuiloader, yui-dom-event, and yahoo-dom-event, as kinglomei stated.

If you are using the minified code, kinglomei's solution works perfectly, but if you are referencing the debug or just unminified code, your code should look like this instead (the minification renames the variables):

 if (o.ie == 0 && ua.indexOf('Trident') != -1){
     o.ie = 11;
 }
jacobfogg

I posted this elsewhere but thought it applies here as well:

I'm using 2.7.0b on a legacy site. Just understand that none of these "fixes" will be exact for you unless you are using the exact same version of the library. This is because as each one was "minimized" various characters were used for the sake of minimization. So you may have to do some hunting. ALSO, bear in mind, this may be different for you depending on if you are using yahoo.js by itself, yahoo-dom-event.js or as in my case, utilities.js. So you will need to make adjustments accordingly.

Step 1:

In utilities/utilities.js & yahoo-dom-event/yahoo-dom-event.js on ln 7 Character 1592 (ln 396 of yahoo.js): Right after:

if(A&&A[1]){C.caja=parseFloat(A[1]);}

But before:

return C;}();

Add this:

if (C.ie==0&&B.indexOf('Trident')!=-1){C.ie=11;}

Step 2:

In editor/editor-min.js & editor/simpleeditor-min.js on line 13 Character 2078 (ln 3135 of editor.js & ln 3135 of simpleeditor.js)

Right after:

(navigator.userAgent.indexOf("Firefox/1.5")!=-1)){

But before:

try{if(this.browser.air)

Add this:

if(this.browser.ie==11){this.browser.ie=0;}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!