Hack: Useful (albeit trivial) javascript addition

Kaballz

Joined: 2002-09-09
Posts: 4
Posted: Thu, 2002-09-12 14:37

The popup_js function has the small problem that if you already have a popped up window open then click another link that would spawn the popup, it will change URL's in the background, but the popup doesn't come to the foreground. The simple addition of a javascript window.focus() after the window.open() solves the problem:

function popup_js($url, $window, $attrs) {
return "javascript:nw=window.open($url,'$window','$attrs');nw.opener=self; nw.focus(); return false;";
}

I hope you'll consider adding this to the distro. :razz: