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 :
#!/usr/bin/perl
print "content-type: text/html \n\n";
print int(rand(1000));
then..
testopener.pl :
#!/usr/bin/perl
print "content-type: text/html \n\n";
print<<OUTPUT
<HTML>
<SCRIPT>
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){
alert('reloading..');
winobj.location.href = url;
}else{
alert('opening as new..');
winobj=window.open(url, 'x', params);
}
if (window.focus) {winobj.focus()}
return false;
}
</SCRIPT>
<BODY>
<FORM ACTION="#">
<INPUT TYPE="BUTTON" VALUE="OPEN WINDOW" ONCLICK="popWindow('t
+estperl.pl');"/>
</FORM>
</BODY>
</HTML>
OUTPUT
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.