notadd / neditor

基于 ueditor的更现代化的富文本编辑器,支持HTTPS
https://demo.neditor.notadd.com/
MIT License
1.91k stars 267 forks source link

关于 Edge 浏览器下无法加载编辑器问题 #114

Closed lujiaxing closed 4 years ago

lujiaxing commented 5 years ago

问题描述: 如图所示. 在 Edge (42.17134.1.0) 浏览器下, 加载编辑器内部页面失败. 有时会提示

0 Permission Denied

有时候则无任何提示. 但编辑器同样无法输入内容, 无法进行任何后续操作. 但是有时候首次打开这个网页后却又一切正常.

image

image

问题根源在此: https://github.com/notadd/neditor/blob/074b4da57d133b85935f5e4f509a960eacf9b34e/_src/core/Editor.js#L501

具体是因为 Edge 不支持 javascript: 这个 URI Scheme 还是因为 javascript:void(); 和运用网站域名不同触发同源策略限制导致此问题这点依然存疑.

建议修改: (此方案非通用方案, 仅供参考)

           var newContentIframe = domUtils.createElement(document, 'iframe', {
               id: 'ueditor_' + me.uid,
               name: 'ueditor_' + me.uid,
               width: "100%",
               height: "100%",
               frameborder: "0",
               src: ""
           });

            var form = domUtils.createElement(document, "form", {
                action: "/File/UEditorContentPage",
                target: ueditor_" + me.uid,
                method: "POST",
                style: "width:0px; height:0px; position:fixed;"
            });

          var 
          iframeCssUrlInput = domUtils.createElement(document, "input", {
            name: "IframeCssUrl", 
            value: options.iframeCssUrl ? utils.unhtml(options.iframeCssUrl) : ""
          }),
          initialStyleInput = domUtils.createElement(document, "input", {
            name: "InitialStyle", 
            value: options.initialStyle || ""
          }),
          isIEInput = domUtils.createElement(document, "input", {
            name: "IsIE", 
            value: ie ? "True" : "False"
          }),
          uidInput = domUtils.createElement(document, "input", {
            name: "UID", 
            value: me.uid
          });

          form.appendChild(iframeCssUrlInput);
          form.appendChild(initialStyleInput );
          form.appendChild(isIEInput);
          form.appendChild(uidInput);

           container.appendChild(newContentIframe);             
           form.submit();

/File/UEditorContentPage 为服务器端渲染的页面. 代替原有的 javascript:void(function(){.....}); 和 "html" 变量的工作, 完成了内嵌页面的初始化和渲染. 这只是临时方案. 不能永久如此.

注: UEditor 同存在此问题.

btw: edge sucks.

zuohuadong commented 5 years ago

edge 暂时不打算支持了, 官方也换 chromium 内核