本文介绍了如何让TinyMCE弹出窗口在Django上工作,其中“static”和“动态”页面是从不同的域提供的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个TinyMCE和Django的问题。我正在使用TinyMCE模块进行基本的表单字段支持。



当TinyMCE想要使用弹出窗口时,问题出在:



在我的开发环境中,静态页面从



static.wdw.ms.local:8888



和Django页面由wdw.ms.local提供:8000



(在生产中,.local:XXXX被删除)



如果我点击html按钮上的编辑(或拼写检查或任何具有弹出窗口的内容),弹出窗口失败。 Firebug告诉我,tinymce。是空(tinymce对象)



我已经编辑了tiny_mce_popup.js,并尝试过这些设置



document.domain ='wdw.ms.local:8000';
以及'wdw.ms.local','static.wdw.ms.local','static.wdw.ms:8888'



他们都会给出这个错误(如Firebug所示):

 < http://wdw.ms.local: 8000和GT;从< http://wdw.ms.local:8000>获取属性Window.tinymce。 
[打破这个错误] var tinymce = null,tinyMCEPopup,tinyMCE; ti ... nyMCEPopup.init();
tinyMCEPopup._wait(); \\\
tiny_mce_popup.js(第5行)

任何想法关于如何让这个工作?



(类似的问题以前已经问过,但是所有的解决方案都涉及更改document.domain设置,这不适用于如果你看这些类似的问题的意见,你会注意到很多其他人都无法让这个工作)

解决方案

将它添加到您的页面上的tinyMCE.init调用之前:

  document.domain ='mydomain.com ; 
tinyMCE.init({
...
});

然后将值:tiny_mce_popup.js更改为:

  document.domain ='mydomain.com'; 

注意:此解决方案适用于Django网站。 p>

参考:


I'm having a problem with TinyMCE and Django. I'm using the TinyMCE module for basic Form field support.

The problem comes when TinyMCE wants to use a popup:

In my development environment, static pages are served from

static.wdw.ms.local:8888

and Django pages are served from wdw.ms.local:8000

(In production, the .local:XXXX is dropped)

If I click on the edit in html button, (or spellcheck, or anything that has a popup), the popup fails. Firebug tells me that "tinymce." is null (the tinymce object)

I've edited the tiny_mce_popup.js and have tried these settings

document.domain = 'wdw.ms.local:8000'; as well as 'wdw.ms.local', 'static.wdw.ms.local', 'static.wdw.ms:8888'

They all give this error (as seen in Firebug):

Permission denied for <http://wdw.ms.local:8000> to get property Window.tinymce from     <http://wdw.ms.local:8000>.
[Break on this error] var tinymce=null,tinyMCEPopup,tinyMCE;ti...nyMCEPopup.init();    
tinyMCEPopup._wait();\ntiny_mce_popup.js (line 5)

Any ideas on how to get this to work?

(Similar questions have been asked here before, but all the solutions involved changing that document.domain setting, which doesn't work for me. If you look in the comments on these similar questions, you'll notice that many other people have been unable to get this to work)

解决方案

Add it to before the tinyMCE.init call on your page:

document.domain = 'mydomain.com';
tinyMCE.init({
   ...
});

And then change the value in: tiny_mce_popup.js to:

document.domain = 'mydomain.com'; 

Note: this solution works for me with a Django website.

Reference: http://wiki.moxiecode.com/index.php/TinyMCE:Cross_domain_loading

这篇关于如何让TinyMCE弹出窗口在Django上工作,其中“static”和“动态”页面是从不同的域提供的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 12:49