Monitoring status of another browser window

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike May

    Monitoring status of another browser window

    Hi

    IE6 Win2k

    The javascript FAQ describes how you can retain a reference to a window that
    you have opened and manipulate the window - focus on it or close it, viz:

    4.10 How do I check to see if a childwindow is open, before opening another?
    var myWin=null;
    function openWin(aURL) {
    if (!myWin || myWin.closed ) {
    myWin=window.op en(aURL,'myWin' );
    } else{
    myWin.location= aURL;
    myWin.focus();
    }
    }

    However, javascript variables appear to be reinitialised each time the
    browser window
    is refreshed so the mechanism described by the FAQ seems to be defeated if
    the user refreshes the page.

    a) Is it true that javascript variables are reinitiliised when the page is
    refreshed?
    b) If a) then is there some other way to monitor a child window from another
    browser window despite user refreshes?

    Thanks
    Mike May



  • Randy Webb

    #2
    Re: Monitoring status of another browser window

    Mike May wrote:
    [color=blue]
    > Hi
    >
    > IE6 Win2k
    >
    > The javascript FAQ describes how you can retain a reference to a window that
    > you have opened and manipulate the window - focus on it or close it, viz:
    >
    > 4.10 How do I check to see if a childwindow is open, before opening another?
    > var myWin=null;
    > function openWin(aURL) {
    > if (!myWin || myWin.closed ) {
    > myWin=window.op en(aURL,'myWin' );
    > } else{
    > myWin.location= aURL;
    > myWin.focus();
    > }
    > }
    >
    > However, javascript variables appear to be reinitialised each time the
    > browser window
    > is refreshed so the mechanism described by the FAQ seems to be defeated if
    > the user refreshes the page.[/color]

    Yep :)
    [color=blue]
    > a) Is it true that javascript variables are reinitiliised when the page is
    > refreshed?[/color]

    Tis indeed the truth. Easy to test to.

    alert(b)
    b = "ok, it has a value now"
    alert(b)
    and then refresh the page......
    [color=blue]
    > b) If a) then is there some other way to monitor a child window from another
    > browser window despite user refreshes?[/color]

    Use a cookie or sessions.

    --
    Randy

    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: Monitoring status of another browser window

      "Mike May" <may@dial.pipex .com> writes:
      [color=blue]
      > Hi
      >
      > IE6 Win2k
      >
      > The javascript FAQ describes how you can retain a reference to a window that
      > you have opened and manipulate the window - focus on it or close it, viz:
      >
      > 4.10 How do I check to see if a childwindow is open, before opening another?
      > var myWin=null;
      > function openWin(aURL) {
      > if (!myWin || myWin.closed ) {
      > myWin=window.op en(aURL,'myWin' );
      > } else{
      > myWin.location= aURL;
      > myWin.focus();
      > }
      > }
      >
      > However, javascript variables appear to be reinitialised each time the
      > browser window
      > is refreshed so the mechanism described by the FAQ seems to be defeated if
      > the user refreshes the page.
      >
      > a) Is it true that javascript variables are reinitiliised when the page is
      > refreshed?[/color]

      Yes. There is no differene between
      [color=blue]
      > b) If a) then is there some other way to monitor a child window from another
      > browser window despite user refreshes?[/color]

      Only very trickily.

      If you try to open a window again with the same name, and it already
      exists, you will be given a new reference to the window. It will probably
      also change the content of the window.

      If you control the content of the opened window, you can have it keep
      check of its parent and write its own reference back to it. That is hard
      to time correctly though.

      /L
      --
      Lasse Reichstein Nielsen - lrn@hotpop.com
      DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      Working...