TinyMCE error: 'Permission denied'
I use TinyMCE to augment one of my Django-driven sites, specifically in the admin edit screen for body content. Recently, after switching this one site from Dreamhost to WebFaction, a Javascript error started occurring in TinyMCE popups (for adding a link and inserting an image). Here's the exact error message I got:
Error: uncaught exception: Permission denied to get property Window.tinyMCE
I did what I always do in situations like this: I googled the details and started combing through the forum posts by people who had the same issue. What I found was two-fold: 1) a number of folks have run into this problem, and 2) from my searches, apparently no one has come across the answer. Oh, and it's completely unrelated to the framework or CMS you're using.
I played around with it from some suggestions I saw, and I was able to fix it, so this post is my attempt to help all those frustrated souls who find themselves in this bind.
The problem is caused by the Javascript files for TinyMCE residing on a different domain (or subdomain, like in my case) as the admin site. The best practice in Django development is to serve static files separately from your Django app; the app needs modpython and Django manages the urls, whereas your static files don't need that overhead. My main domain for this particular project is watercooler.biola.edu and the media files live at media.watercooler.biola.edu.
If you have a similar setup, here's the solution. At the top of the tiny_mce_popup.js file (inside the tiny_mce folder), define the variable document.domain. Here's the line from my code:
document.domain = 'watercooler.biola.edu';
This tells the browser that even though the Javascript resides on media.watercooler.biola.edu, the relevant domain is watercooler.biola.edu and it's okay for this code to interact with pages on that (sub)domain.
Hopefully this benefits fellow TinyMCE users out there, whether you're using Django, Joomla, WordPress, Drupal, or what-have-you.
By the way, since coming up with the solution, I found a page at Mozilla on the Same Origin Policy which is what this problem stems from. So it's certainly documented in places but it didn't come up from my search terms.
Recent Posts
-
- Comments and ColdFusion
- 08/29
- 2
Regarding a flaw or two in the comments system (and/or the site's messaging) and the response to my 'ColdFusion is Dead' entry.
-
- The Redesign
- 07/22
- 4
The day I've been working towards for over a year has finally arrived: I have launched a complete redesign of my web site.
-
- ColdFusion is Dead
- 07/02
- 38
Regarding Adobe's announcement that they're adding a fresh layer of paint to their dying language.
-
- Should I Be Worried?
- 05/24
- 0
A disturbing problem with my iMac, and discovering the beauty of a UPS.
-
- LogoMaid: Brazen Logo Theft
- 03/25
- 0
Doing my part to spread the word about this thieving company.
In Between is the blog of Dave Lowe, a web designer and developer in the Orange County (Southern California) area.
ShiftWorship
Bummer, this didn't work for me through Joomla! More searching I suppose....
Permalink