Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > A new pop up window will not obey a close command from original page.

Reply
Thread Tools

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

 
 
Marc
Guest
Posts: n/a
 
      11-23-2003
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 -->
 
Reply With Quote
 
 
 
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      11-23-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) (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 - (E-Mail Removed)
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
 
 
 
Marc
Guest
Posts: n/a
 
      11-23-2003
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 <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> (E-Mail Removed) (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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Making JTable column widths obey me Daniel Luis dos Santos Java 2 02-16-2010 12:37 AM
beginner: how to close a pop up window before opening an other pop up Madame Blablavatsky Javascript 8 09-16-2005 10:27 PM
close current window using window.close() Shang Wenbin Javascript 10 09-02-2005 12:16 AM
Close pop window and refresh the parent window J P Singh ASP General 3 02-11-2004 01:59 AM
Registry access permission doesn't obey impersonated user Karim ASP .Net Security 7 09-04-2003 10:27 PM



Advertisments