Where's my popup gone?
Popup windows are quite common in web applications (other than for annoying adverts, I mean) but one drawback they can have is that they can disappear behind the main window and re-clicking the link or button that launched them in the first place does not bring then to focus again.
So, here's a solution. It relies on creating the window as a named object, which you can then check for the presence of, see if its closed and also change the focus to.
var myWindow=null;Lets looks at the key features here:
function popupWindow() {
if (myWindow && !myWindow.closed) {
myWindow.focus();
} else {
url="popupwindow_page.html";
myWindow=window.open(url,'name','width=200,height=200');
}
}
1. we start by defining a variable 'myWindow' which will eventually contain the 'object' that is the popup window itself. This means that we can later test for it without running into 'undefined' problems.
2. when we create our popup, we define it as this named object, making targetting easier
3. so, what the function does is first to check to see if the myWindow object already exists and is NOT closed (ie: open). If it is, we simply switch the browser focus to it, which will bring it to the front. If not, we create the popup window using whatever parameters you want
We launch the function with an ONCLICK action on a button or link in the body of the page, eg:
<INPUT TYPE="button" VALUE="click for popup" ONCLICK="popupWindow();" TITLE="click to open the popup window">Technorati tags: JavaScript popup window focus

"Work begins on largest wind farm


PHP. How do you check to see if a variable is empty, when it might have a value of zero? empty($var) returns true if its zero, so you can't use that. I found that you need to test for $var===""






This neat little device promises to bring a little revolution to fast-working sports photographers wanting to get images from camera to client even faster than is possible already. Its basically a flash card with an 802.11 wireless transmitter built-in. There must be some clever buffering because the transmission speed even of the g-flavour of 802.11 would not be fast enough to keep up with a Canon 1D of Nikon D2H working at its top frame rate - even for a short burst.
Local popstar
The absolute "must attend" event for serious Trekkies everywhere is occouring later this year as Christies auction off "official Star Trek contents from the archives of CBS Paramount Television Studios. Over 1,000 lots from the never-before-released archives of CBS Paramount Television will include material from all of the Star Trek television series and movies, encompassing costumes, props, weapons, set dressings, detailed models of the Enterprise and various alien ship and space stations."
Picked up a bargain of a new home computer from 
Forecast: sunshine. Actual weather today: pooring with rain. Still, very glad of the drop in temperature - yesterday was horrible.
Rain - here? Some hope. BBC weather forcast for home town underestimates the temperature by at least 3 degrees C - it's actually reached 29 here today - and the threatened "thundery downpoors" are nowhere to be seen.
By this time of day, sixty two years ago, hundreds of men had lost their lives on the beaches of Normandy. I speak of course of D-Day, 6th June 1944, the beginning of the liberation of Europe. Having trained for months, some didn't even make it out of their landing craft, cut down by the defences built along the French coast. Spare a moment to think of those whose blood soaked into the sands of Gold, Juno, Sword, Omaha and Utah.


