View Full Version : window.open and server side data (PERL)

Mar 5th, 2008, 04:18 AM
hi brothers, this seems to be one interesting situation but i can't figure out what's going on. IS there any way to solve this?

problem : if a window (popup) already exist and if window.open is called again, it will not load the contents of the perl at all! I need the popup window to always have the latest data whenever decides to open the window.

to test :

1.) execute testopener.pl
2.) click on the open window button, a popup appears with a randomly generated number. Remember the number.
3.) go back to testopener.pl page, hit refresh (so that it'll clean up all the window variable).
4.) now click on open window button again, you'll notice that the number did not change! (but it's actually calling window.open)

firstly, have a file called :

testperl.pl :

print "content-type: text/html \n\n";

print int(rand(1000));


testopener.pl :

print "content-type: text/html \n\n";

var winobj; //is there no way to do this beside declaring a global?
function popWindow(url){

var width = 700;
var height = 500;
var left = (screen.width - width)/2;
var top = (screen.height - height)/2;
var params = 'width='+width+', height='+height;

params += ', top='+top+', left='+left;
params += ', directories=no';
params += ', location=no';
params += ', menubar=no';
params += ', resizable=no';
params += ', scrollbars=yes';
params += ', status=no';
params += ', toolbar=no';

//refresh if window is still open
if(winobj && !winobj.closed){
winobj.location.href = url;
alert('opening as new..');
winobj=window.open(url, 'x', params);

if (window.focus) {winobj.focus()}

return false;


<INPUT TYPE="BUTTON" VALUE="OPEN WINDOW" ONCLICK="popWindow('testperl.pl');"/>