Detecting sender / focused element in sender?

Discussion in 'Javascript' started by jodleren, Jan 29, 2008.

  1. jodleren

    jodleren Guest

    Hi

    I want to open a window using JS, when a button is pressed. In the new
    window I'd like to check for which button was pressed.
    For cetain reasons, I'd like not to have that in the URL.

    What I have is

    function whatever(input)
    {
    win3=window.open("myfile.php?dir=" +
    encodeURIComponent(input),"dm_popup","width=500,height=550,scrollbars=yes,resizable=yes");
    return false;
    }

    and <p><input name="btn_sel1" type="button" value="..."
    onclick="OpenRootDirSel(textbox1.value);">&nbsp;&nbsp;</p>

    And here I'd like to add btn2 and textbox2 - which should work the
    same way.
    The point is, that the new window uses JS too to set the value of the
    related textbox.

    Any ideas?

    WBR
    Sonnich
    jodleren, Jan 29, 2008
    #1
    1. Advertising

  2. jodleren <> writes:

    > Hi
    >
    > I want to open a window using JS, when a button is pressed. In the new
    > window I'd like to check for which button was pressed.
    > For cetain reasons, I'd like not to have that in the URL.


    Set it in the opener window:

    window.name_of_button = whatever;

    then from the new window do:

    name_of_button = window.opener.name_of_button;

    http://developer.mozilla.org/en/docs/DOM:window.opener

    AFAIK this only works for windows that have been opened via window.new()

    Joost.
    Joost Diepenmaat, Jan 29, 2008
    #2
    1. Advertising

  3. Joost Diepenmaat wrote:
    > [...]
    > name_of_button = window.opener.name_of_button;


    var ... = ...

    And the `opener' property should be tested if it still refers to an open
    Window object. See the FAQ.

    > http://developer.mozilla.org/en/docs/DOM:window.opener
    >
    > AFAIK this only works for windows that have been opened via window.new()


    You would be correct if you meant window.open().


    PointedEars
    --
    var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
    ) // Plone, register_function.js:16
    Thomas 'PointedEars' Lahn, Jan 31, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Showjumper
    Replies:
    2
    Views:
    1,785
    Showjumper
    Aug 2, 2003
  2. Nima

    J2ME focused newsgroup

    Nima, Apr 5, 2004, in forum: Java
    Replies:
    1
    Views:
    334
    alan jeeves
    Apr 6, 2004
  3. Dylan Parry
    Replies:
    2
    Views:
    534
  4. Replies:
    0
    Views:
    384
  5. Replies:
    0
    Views:
    346
Loading...

Share This Page