changing opener

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Diana Coppenbarger

    changing opener

    Hi,

    I have a calendar program that is popped up by a HTML so that the user
    can choose a specific date to be filled in via javascript from the
    calendar program. I am using window.open() to start the calendar
    program and then calling my own function "javascript:ope ner.setDate()"
    to set the date back on the main window. This all works fine if I use
    the current month that is displayed, but as soon as I have to rebuild
    the calendar because they want to go to another month, the opener is
    not being set correctly. The javascript for popping up the calendar
    window and changing the month looks like:

    function popupCal
    {
    calWin = window.open('/cgi-script/calWin','calWin ');
    }

    function changeMonth(mon th)
    {
    calWin.open('/cgi-script/calWin'+month,' calWin');
    alert(calWin.op ener.location);
    if(calWin.opene r == calWin){
    calWin.opener = this; // reset back to main window
    }
    alert(calWin.op ener.location);
    }

    (The alerts were added for debugging.) This all works just fine in
    IE, but when trying from Netscape 7.1 or Mozilla, the calWin.opener is
    not reset and the alert says the calWin.opener.l ocation is the same as
    the calWin.location . Everything I have read about opener says you can
    reset it like this, but it doesn't seem to work. Does anyone have any
    suggestions?

    -Diana
  • DU

    #2
    Re: changing opener

    Diana Coppenbarger wrote:[color=blue]
    > Hi,
    >
    > I have a calendar program that is popped up by a HTML so that the user
    > can choose a specific date to be filled in via javascript from the
    > calendar program. I am using window.open() to start the calendar
    > program and then calling my own function "javascript:ope ner.setDate()"
    > to set the date back on the main window.[/color]



    This all works fine if I use[color=blue]
    > the current month that is displayed, but as soon as I have to rebuild
    > the calendar because they want to go to another month, the opener is
    > not being set correctly.[/color]


    Please elaborate on "the opener is not being set correctly". What do you
    mean? Are you saying that the date is not pasted into some input field
    in the opener?
    Can you provide an url of your page? That would be so convenient here.

    The javascript for popping up the calendar[color=blue]
    > window and changing the month looks like:
    >
    > function popupCal
    > {
    > calWin = window.open('/cgi-script/calWin','calWin ');
    > }[/color]

    I would set explicitly this calWin as a global variable.
    [color=blue]
    >
    > function changeMonth(mon th)
    > {
    > calWin.open('/cgi-script/calWin'+month,' calWin');
    > alert(calWin.op ener.location);
    > if(calWin.opene r == calWin){[/color]

    The boolean conditional expression should always be false. Immediately
    after creating a secondary window, you're querying if the opener is a
    pointer reference to the one of its own secondary window. So, that
    should always be false.
    [color=blue]
    > calWin.opener = this; // reset back to main window
    > }[/color]

    This sort of assignment will (soon?) become impossible to do once
    browsers tighten their security. Fooling around with pointers like that
    shouldn't be possible. E.g.: Mozilla: NS_ERROR_XPC_BA D_CONVERT_JS

    [color=blue]
    > alert(calWin.op ener.location);
    > }
    >
    > (The alerts were added for debugging.) This all works just fine in
    > IE[/color]

    it does??

    , but when trying from Netscape 7.1 or Mozilla, the calWin.opener is[color=blue]
    > not reset and the alert says the calWin.opener.l ocation is the same as
    > the calWin.location . Everything I have read about opener says you can
    > reset it like this[/color]

    Ok, then. Please show me the links, references, documentation,
    preferably official documentations.

    , but it doesn't seem to work. Does anyone have any[color=blue]
    > suggestions?
    >
    > -Diana[/color]


    Best is to start by provide an url to your page.

    DU
    --
    Javascript and Browser bugs:

    - Resources, help and tips for Netscape 7.x users and Composer
    - Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x


    Comment

    • Richard Cornford

      #3
      Re: changing opener

      "DU" <drunclear@ho t-R-E-M-O-V-E-mail.com> wrote in message
      news:blvq5s$5m$ 1@news.eusc.int er.net...
      <snip>[color=blue][color=green]
      >> function changeMonth(mon th)
      >> {
      >> calWin.open('/cgi-script/calWin'+month,' calWin');[/color][/color]
      <snip>

      It is probably pertinent that this statement has no assignment. If we
      assume that a global variable called "calWin" has been assigned a
      reference to a pop-up window at this point and the above statement calls
      the open method of that window in order to open another window (and I
      cannot see any reason for doing that as this window has a perfectly good
      wiondow.open function of its own (subject to browser support and content
      inserting proxies)), then the window reference for this new pop-up is
      just being discarded.

      In principal neither calWin nor it's opener will be effected in any way
      by this operation and the second pop-up window is inaccessible form
      either this window or the first - calWin - pop-up as neither hold a
      reference to it.

      Richard.


      Comment

      • DU

        #4
        Re: changing opener

        Richard Cornford wrote:[color=blue]
        > "DU" <drunclear@ho t-R-E-M-O-V-E-mail.com> wrote in message
        > news:blvq5s$5m$ 1@news.eusc.int er.net...
        > <snip>
        >[color=green][color=darkred]
        >>>function changeMonth(mon th)
        >>>{
        >>> calWin.open('/cgi-script/calWin'+month,' calWin');[/color][/color]
        >
        > <snip>
        >
        > It is probably pertinent that this statement has no assignment. If we
        > assume that a global variable called "calWin" has been assigned a
        > reference to a pop-up window at this point and the above statement calls
        > the open method of that window in order to open another window[/color]

        Yes... I totally missed that! Doh!

        (and I[color=blue]
        > cannot see any reason for doing that as this window has a perfectly good
        > wiondow.open function of its own (subject to browser support and content
        > inserting proxies)), then the window reference for this new pop-up is
        > just being discarded.
        >[/color]

        Well, it's a returned value which is never used.
        [color=blue]
        > In principal neither calWin nor it's opener will be effected in any way
        > by this operation and the second pop-up window is inaccessible form
        > either this window or the first - calWin - pop-up as neither hold a
        > reference to it.
        >
        > Richard.
        >
        >[/color]

        DU
        --
        Javascript and Browser bugs:

        - Resources, help and tips for Netscape 7.x users and Composer
        - Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x


        Comment

        • Diana Coppenbarger

          #5
          Re: changing opener

          I am a bit new at javascript, so I apologize if I seem to not know
          what I am doing. Here is a link to the script in question:

          http://www.lle.rochester.edu/~dcop/calendarTest.html.

          Click on the picture of the calendar to run the script and then click
          on one of the arrows to change to a different month. Once you are in
          the different month, if you are running in Netscape or Mozilla, it all
          stops working.

          When I type "javascript :", it says the functions are not defined.
          Please note that the debugging alerts are not included in this link.

          -Diana


          DU <drunclear@ho t-R-E-M-O-V-E-mail.com> wrote in message news:<bm071d$57 e$1@news.eusc.i nter.net>...[color=blue]
          > Richard Cornford wrote:[color=green]
          > > "DU" <drunclear@ho t-R-E-M-O-V-E-mail.com> wrote in message
          > > news:blvq5s$5m$ 1@news.eusc.int er.net...
          > > <snip>
          > >[color=darkred]
          > >>>function changeMonth(mon th)
          > >>>{
          > >>> calWin.open('/cgi-script/calWin'+month,' calWin');[/color]
          > >
          > > <snip>
          > >
          > > It is probably pertinent that this statement has no assignment. If we
          > > assume that a global variable called "calWin" has been assigned a
          > > reference to a pop-up window at this point and the above statement calls
          > > the open method of that window in order to open another window[/color]
          >
          > Yes... I totally missed that! Doh!
          >
          > (and I[color=green]
          > > cannot see any reason for doing that as this window has a perfectly good
          > > wiondow.open function of its own (subject to browser support and content
          > > inserting proxies)), then the window reference for this new pop-up is
          > > just being discarded.
          > >[/color]
          >
          > Well, it's a returned value which is never used.
          >[color=green]
          > > In principal neither calWin nor it's opener will be effected in any way
          > > by this operation and the second pop-up window is inaccessible form
          > > either this window or the first - calWin - pop-up as neither hold a
          > > reference to it.
          > >
          > > Richard.
          > >
          > >[/color]
          >
          > DU[/color]

          Comment

          • DU

            #6
            Re: changing opener

            Diana Coppenbarger wrote:[color=blue]
            > I am a bit new at javascript, so I apologize if I seem to not know
            > what I am doing. Here is a link to the script in question:
            >
            > http://www.lle.rochester.edu/~dcop/calendarTest.html.
            >[/color]

            File not found!
            I had the chance to examine the file though before it went off line. I
            am convinced you do not need server-side interaction to create that
            [previous or next] month calendar grid. Client-side script will suffice.

            The
            function changeMonth(mon th)
            should be in the
            cgi-script/calWin
            file instead of its opener. Accessing that function from the opener just
            makes things unneedlessly more complex, I think. Anyway, I'm sure your
            interactive date/calendar picker can be made with only client-side script.
            [color=blue]
            > Click on the picture of the calendar to run the script and then click
            > on one of the arrows to change to a different month. Once you are in
            > the different month, if you are running in Netscape or Mozilla, it all
            > stops working.
            >
            > When I type "javascript :", it says the functions are not defined.
            > Please note that the debugging alerts are not included in this link.
            >
            > -Diana
            >
            >[/color]

            DU
            --
            Javascript and Browser bugs:

            - Resources, help and tips for Netscape 7.x users and Composer
            - Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x


            Comment

            Working...