19 Mar

Focus and blur with popups

March 19th, 2007 — 10:07 am Chris

I know, I know, as soon as you see the word popups you think the worst. But they do serve a purpose, especially in web applications. We only use one popup and it’s really out of necessity. Our popup is the main content editing window. I created it this way because I want to see the page I’m working on while I edit the contents for the page. In this case, the popup is a good choice.

In fact, just recently (with the v0.3.2 release) we added a more dynamic preview to the system. Now, when you preview your content in the editing window (popup) it also updates the block on the actual page, thus providing a much more accurate representation of the content.

However, one of the minor annoyances in previous versions was that clicking the edit icon would not bring the popup into focus if it was already opened. This used to work with a simple this.focus() call in onload, but somewhere it stopped working.

Luckily, there is a solution (it’s working for me, at least): you have to also blur the parent window:

  this.focus(); 
  this.opener.blur();

So, if you are having trouble with popups, try using the combination of focus and blur.

Add comment

You are adding a new comment