Sorry I'm a bit confused, where does this bit of JS go? On the page with the editor on I'd guess?
Your help pages often give useful sections of code but then no real advice on where they need to be placed for people who aren't as familiar with your product. Please give full information in this sort of documentation, thanks.