new at js - question about window objects

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

    #1

    new at js - question about window objects

    I run a website with most pages built on a template with nav bar etc.

    On one of my template pages (call it "A"), I have links to diagrams that
    open in js-defined "popup" type windows (call it "B"). At the bottom of the
    diagram is an option to click on a link for a 'text version' of the diagram.
    I did manage to get the popup to close by embedding [
    onclick="self.c lose()" ] in the anchor tag.

    However the text version opens a new window in the template series (call it
    "C"), so both "A" and "C" are now open.

    Is there any JS code I can implement to force the text-version to open in
    the template window ("A") that is already open (ie, the parent of the popup
    window) ...?

    thanks for any pointers ...

    rusty


  • Laurent Bugnion, GalaSoft

    #2
    Re: new at js - question about window objects

    Hi,

    rusty wrote:[color=blue]
    > I run a website with most pages built on a template with nav bar etc.
    >
    > On one of my template pages (call it "A"), I have links to diagrams that
    > open in js-defined "popup" type windows (call it "B"). At the bottom of the
    > diagram is an option to click on a link for a 'text version' of the diagram.
    > I did manage to get the popup to close by embedding [
    > onclick="self.c lose()" ] in the anchor tag.
    >
    > However the text version opens a new window in the template series (call it
    > "C"), so both "A" and "C" are now open.
    >
    > Is there any JS code I can implement to force the text-version to open in
    > the template window ("A") that is already open (ie, the parent of the popup
    > window) ...?
    >
    > thanks for any pointers ...
    >
    > rusty[/color]

    A pop-up always knows her opener. The "opener" property is a reference
    to the Window object which represents the pop-up's opener.

    In other words, instead of closing B and opening C, you can close B and
    modify the location of A.

    The code would be something like:

    <A HREF="#"
    ONCLICK="loadTe xtVersion();">L ink text</A>

    with:

    function loadTextVersion ()
    {
    opener.location = "textVersion.tx t";
    self.close();
    }

    HTH,

    Laurent
    --
    Laurent Bugnion, GalaSoft
    Webdesign, Java, JavaScript: http://www.galasoft-LB.ch
    Private/Malaysia: http://mypage.bluewin.ch/lbugnion
    Support children in Calcutta: http://www.calcutta-espoir.ch

    Comment

    • rusty

      #3
      Re: new at js - question about window objects

      thanks Laurent, worked like a charm!


      Comment

      Working...