In Between
by Dave Lowe

TinyMCE error: 'Permission denied'

5 comments

Posted: Mar 26, 2007

Tags: DOM Scripting

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

  • 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 day I've been working towards for over a year has finally arrived: I have launched a complete redesign of my web site.

  • Regarding Adobe's announcement that they're adding a fresh layer of paint to their dying language.

  • A disturbing problem with my iMac, and discovering the beauty of a UPS.

  • Doing my part to spread the word about this thieving company.

Comments

  1. 2007/09/11 10:45 a.m. matt said...

    Bummer, this didn't work for me through Joomla! More searching I suppose....

    Permalink

  2. 2007/10/11 1:08 p.m. Mauv said...

    I thought this was the issue. Thanks very much for verifiying! (Found your through google.)

    Permalink

  3. 2007/10/22 10:30 p.m. Josh said...

    Great post, however after following your method - tinyMCE was still not working for me,

    until,

    I added document.domain to ALL 3 tinyMCE files (used for the pop ups) - I guess this facilitates cross domain requests in Firefox - I'm still running across errors in ie7 though ;_(

    Permalink

  4. 2007/11/08 9:16 a.m. Trevor Gryffyn said...

    Great information, Dave. This is the right solution even though I didn't get it to work properly. hah.

    There's a workaround here.

    (basically access your site using the domain that it's expecting instead of trying to define cross site permissions).

    I'm using Joomla, so a quick tip for the Joomla users. In the Site -> Global Configuration area there's a tab called "Server".

    Under that tab, you'll see "Live Site". This is the address that TinyMCE is going to be trying to use. If your "Live Site" is defined as "domain.com" and you're accessing it through "www.domain.com", then you'll probably get the error describe on this page.

    You can edit your 'Live Site' by manually editing "configuration.php" in your root Joomla directory: Described here.

    Once I figure out why setting document.domain = 'www.domain.com'; gives me an "Illegal value" error, I'll try to come back and post here again.

    Again, this is the correct solution, I believe, even if I didn't get it to work properly. I thought this other information would be a good addition since this was one of the first pages that came up when I did a search.

    Thanks Dave!

    -Trevor

    Permalink

  5. 2008/01/10 2:10 a.m. Rob Lewis said...

    Had the same problem with TinyMCE in Wordpress - your solution fixed that too.

    Thanks very much!

    Permalink

Comments are closed.

About

Photo of Dave Lowe In Between is the blog of Dave Lowe, a web designer and developer in the Orange County (Southern California) area.

Read more

Contact: email 'dave' at this domain.

Made with Django.

Hosted by WebFaction

XHTML 1.0 Strict, CSS.