Author Topic: Kill pop-up windows & frames problem  (Read 3145 times)

strapatz2

  • Newbie
  • *
  • Posts: 7
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • Email
Kill pop-up windows & frames problem
« on: March 22, 2002, 04:50:05 PM »
The technique using WindowOpen.js does not work correctly on the page http://www.belastingdienst.nl (in Dutch). This page consists of several frames. To reproduce the problem, click "Elektronische aangifte", then "Het Aangifteprogramma", then "downloaden". Most of the time, nothing happens. My impression is that the filter compares the local time of the computer with the time the link was clicked. Only when the local time is XX:YY:00 or XX:YY:01, the link works correctly! Is there an elegant way to solve this issue?

Best regards,
   Lennert.
 

strapatz2

  • Newbie
  • *
  • Posts: 7
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • Email
Kill pop-up windows & frames problem
« Reply #1 on: March 22, 2002, 10:49:49 PM »
Hi,

It turns out that the unwanted interaction between killing pop-up windows and JavaScripts embedded in frames is causing this problem. Basically, it is a scope problem. One frame calls a function within another frame, and that frame knows nothing about the right "PrxLC" variable. My idea is to create only a single (global) PrxLC variable when dealing with frames to avoid this. Here is my suggestion for improving the "Kill pop-up windows" filter. Please let me know if this works!

<!--//--><script>
if (top.length<=1)
{
  var PrxLC=new Date(0);
}
else
{
  alert("using frames in " + document.URL);
  top.document.PrxLC=new Date(0);
  alert(top.length);
}
var PrxModAtr=0;
var PrxInst; if(!PrxInst++) PrxRealOpen=window.open;

function PrxOMUp()
{
  if (top.length<=1)
  {
    PrxLC=new Date()
  }
  else
  {
    top.document.PrxLC=new Date()
  }
}

function PrxNW() { return(this.window); }
function PrxOpen(url,nam,atr)
{
  var PrxLCloc;

  if (top.length<=1)
  {
    PrxLCloc = PrxLC;
  }
  else
  {
    PrxLCloc = top.document.PrxLC;
  };

  if(PrxLCloc)
  {
    var cdt=new Date();
    cdt.setTime(cdt.getTime()-PrxLCloc.getTime());
    if(cdt.getSeconds()<9)
    {
      return(PrxRealOpen(url,nam,PrxWOA(atr)));
    }
  }
  return(new PrxNW());
}

function PrxWOA(atr){
  var xatr="location=yes,status=yes,resizable=yes,toolbar=yes,scrollbars=yes";
  if(!PrxModAtr) return(atr);
  if(atr){
    var hm;
    hm=atr.match(/height=[0-9]+/i);
    if(hm) xatr+="," + hm;
    hm=atr.match(/width=[0-9]+/i);
    if(hm) xatr+="," + hm;
  }
  return(xatr);
}
window.open=PrxOpen;
</script>


Greets,
  Lennert.
 

Arne

  • Administrator
  • Hero Member
  • *****
  • Posts: 778
    • ICQ Messenger - 1448105
    • AOL Instant Messenger - aflaaten
    • Yahoo Instant Messenger - arneflaa
    • View Profile
    • http://
    • Email
Kill pop-up windows & frames problem
« Reply #2 on: March 23, 2002, 07:37:44 AM »
Hi Lennert and welcome,

This sounds very interesting. I am sorry that I don't have time to test it today, but I will try it as soon as possible.


Best wishes
Arne
Imici username: Arne
Best wishes
Arne
Imici username= Arne

strapatz2

  • Newbie
  • *
  • Posts: 7
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • Email
Kill pop-up windows & frames problem
« Reply #3 on: March 26, 2002, 10:33:19 AM »
Hi,

Thanks Arne. Of course, the "alert's" should be removed before testing this script. Somehow I posted a debug version to this forum. At the moment, I am not sure if this technique handles IFRAMEs correctly.

Greetings,
  Lennert.