A new pop up window will not obey a close command from original page.

Discussion in 'Javascript' started by Marc, Nov 23, 2003.

  1. Marc

    Marc Guest

    I am trying to create a new window from which the original page can
    close that new window. For some reason the following code will not
    work. Passing the window.open command to a variable called myWindow
    does not work with the mouse event, but it seems to work fine with a
    javascript: URL command. I would prefer to do it with the mouse event.

    Please assist. I can not find any documentation for this in any of my
    books.


    <!-- Code begins -->

    <html>
    <body>

    <a href="#" onMouseDown="var myWindow=window.open('text.html',
    'bobby', 'width=200, height=200');">Open</a>.
    <a href="#" onMouseDown="myWindow.close();">Close</a>.

    </body>
    </html>

    <!-- Code ends -->
     
    Marc, Nov 23, 2003
    #1
    1. Advertising

  2. Re: A new pop up window will not obey a close command from originalpage.

    (Marc) writes:

    > I am trying to create a new window from which the original page can
    > close that new window. For some reason the following code will not
    > work. Passing the window.open command to a variable called myWindow
    > does not work with the mouse event, but it seems to work fine with a


    > <a href="#" onMouseDown="var myWindow=window.open('text.html',


    The contents of the onmousedown attribute value is used as the body of
    a function. That means that "var myWindow" declares a local variable
    in that function ....


    > <a href="#" onMouseDown="myWindow.close();">Close</a>.


    .... which is not visible from another function.
    Drop the "var" and it should work.

    Btw,

    > 'bobby', 'width=200, height=200');">Open</a>.


    spaces in the configuration string confuzes some browsers. Remove the
    space before "height", and it should work in more browsers.

    Add ",resizable=yes". In the cases where 200x200 isn't enough (and
    with user stylesheets, there can be some that you can't predict),
    you should allow the user to resize the window. If the content fits,
    he probably won't resize anything, so it doesn't hurt to add it.

    /L
    --
    Lasse Reichstein Nielsen -
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
    'Faith without judgement merely degrades the spirit divine.'
     
    Lasse Reichstein Nielsen, Nov 23, 2003
    #2
    1. Advertising

  3. Marc

    Marc Guest

    Thank you. That definately worked. I also found articles on local and
    global variables, and I have a better understanding of how it works.

    I will also be sure to follow the guidelines for the pop up window.

    Thanks,
    Marc

    Lasse Reichstein Nielsen <> wrote in message news:<>...
    > (Marc) writes:
    >
    > > I am trying to create a new window from which the original page can
    > > close that new window. For some reason the following code will not
    > > work. Passing the window.open command to a variable called myWindow
    > > does not work with the mouse event, but it seems to work fine with a

    >
    > > <a href="#" onMouseDown="var myWindow=window.open('text.html',

    >
    > The contents of the onmousedown attribute value is used as the body of
    > a function. That means that "var myWindow" declares a local variable
    > in that function ....
    >
    >
    > > <a href="#" onMouseDown="myWindow.close();">Close</a>.

    >
    > ... which is not visible from another function.
    > Drop the "var" and it should work.
    >
    > Btw,
    >
    > > 'bobby', 'width=200, height=200');">Open</a>.

    >
    > spaces in the configuration string confuzes some browsers. Remove the
    > space before "height", and it should work in more browsers.
    >
    > Add ",resizable=yes". In the cases where 200x200 isn't enough (and
    > with user stylesheets, there can be some that you can't predict),
    > you should allow the user to resize the window. If the content fits,
    > he probably won't resize anything, so it doesn't hurt to add it.
    >
    > /L
     
    Marc, Nov 23, 2003
    #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. Daniel Luis dos Santos

    Making JTable column widths obey me

    Daniel Luis dos Santos, Feb 15, 2010, in forum: Java
    Replies:
    2
    Views:
    603
    John B. Matthews
    Feb 16, 2010
  2. Karim
    Replies:
    7
    Views:
    233
    Karim
    Sep 4, 2003
  3. J P Singh
    Replies:
    3
    Views:
    320
    Howard Rothenburg
    Feb 11, 2004
  4. Danny
    Replies:
    1
    Views:
    141
    kaeli
    Jul 21, 2004
  5. Madame Blablavatsky
    Replies:
    8
    Views:
    182
    Dr John Stockton
    Sep 16, 2005
Loading...

Share This Page