473,324 Members | 2,268 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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

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 -->
Jul 20 '05 #1
2 3803
ma******@yahoo.com (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 - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
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 <lr*@hotpop.com> wrote in message news:<he**********@hotpop.com>...
ma******@yahoo.com (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

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Display Name | last post by:
the customer I'm developing a site for uses a canned form-parsing page that allows her to have an email subscription opt-in page add emails to a list she can manage using a link that you point your...
3
by: sentinel | last post by:
Hi all, I'm trying to reload a frame from a pop-up, but really cannot figure this out. Within my index.htm file, I make a link to call a pop-up frame with a javascript function that calls the...
19
by: Darren | last post by:
I have a page that opens a popup window and within the window, some databse info is submitted and the window closes. It then refreshes the original window using window.opener.location.reload(). ...
4
by: JeffP | last post by:
I want to add a short-cut to a windows app similar to launching from a windows run line a New window, to prevent changing an existing browser window from moving off a current logged in session...
4
by: GrantS | last post by:
I am having a problem closing a popup window opened modally. When I try to close the window (when the user hits save button and the data has been processed), the Popup window opens as a full screen...
2
by: Cheryl | last post by:
Hi, I have encounter a problem.Language use is C#. I would like to open a new window (is a modal window, where I m not able to switch from parent window after this window is open)from the parent...
2
by: Mark | last post by:
Any suggestions on how to go about generating a popup, giving the user a way of searching for something, and then taking their selection after closing the pop-up and populating the parent form with...
4
by: sam.s.kong | last post by:
Hello! I opened a new window using 'resizable=no'. Can the child window make itself resizable even if it's opened with 'resizable=no'? For example: <body onload="javascript:...
2
by: jackson2005 | last post by:
OK, I need to do three different things. On the ONLOAD event I would like a popup box to open. In this popup box I need two text boxes. One for the UserName and one for the BillingTo name. ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.