473,396 Members | 1,935 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,396 software developers and data experts.

window.opener problem

Gotta problem. I have a page that onload a popup window comesup, within that popup window there is a link to another .htm page. I need that link to display the .htm file in the main browser window.(use the opener keyword to reference the main browser window, and the location.href property to specify the document to be displayed(form.htm)in that window., and slo close the current window.
Below is what i have right now, it loads the popup window(subscriptions)correctly, when i press the link in the popup window it opens the form.htm in the popup window instead of the main browser window.
Expand|Select|Wrap|Line Numbers
  1. <title>Subscription</title>
  2. <link href="cover.css" rel="stylesheet" type="text/css" />
  3. <script type="text/javascript">
  4. function showForm(URL){    
  5.       window.opener.location.href="form.htm";
  6.       window.close();
  7. }                    
  8.  
  9. </script>
  10. </head>
  11.  
  12. <body>
  13.  
  14. <div id="main">
  15. <p><a href="form.htm">
  16.    <b>Order 12 issues <br />for: $9.95*</b>
  17.    </a>
  18. </p>
  19. <p><img src="cover.jpg" alt="The Civil War Journal" /><br />
  20.    *25% off the <br />newsstand price!</p>
  21. </div>
  22.  
  23. </body>
  24. </html>
  25.  
  26.  
The form.htm still opens in the popup window instead of the main browser window
Sep 3 '09 #1
2 3400
Dormilich
8,658 Expert Mod 8TB
@rexdreamer
why should it open in the main window? although you made a JS function, it is called nowhere, leaving the link as it is (i.e. normal behaviour).
Sep 3 '09 #2
Frinavale
9,735 Expert Mod 8TB
I think you need to use a closure, and its always a good idea to check if the parent window is open before referring to it.
Expand|Select|Wrap|Line Numbers
  1. if(window.opener && !window.opener.closed){
  2.   var winOpener = window.opener;
  3.   winOpener.location.href="form.htm";
  4.   window.close();
  5. }
Sep 3 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

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...
1
by: MrFez | last post by:
I have an webform from which I open a child window to display a calendar. When a date is selected in the calendar window it attempts to set the value of a textbox in the main (parent) window by...
5
by: Dave | last post by:
I see this problem in IE but not Firefox. I have a page that opens a second page as a dialog box. If the Dialog is relaunched from a second instance on the page the Dialog window is reused, the...
1
by: fogwolf | last post by:
First a basic outline of what I am trying to do: I want to have a page spawn a pop-up when you click "submit" on its form. On this pop-up page there will be another form. When you click "submit"...
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(). ...
2
by: David | last post by:
Hey all, I have a script that dynamically sets the window.onunload of the current window to point to a function that, when run, will close another dependent window (if it's opened). This works...
7
by: MrFez | last post by:
Through some investigation it appears that selecting "Every visit to the page" for the IE caching setting "Check for new version of stored pages" causes the window.opener property of child windows...
5
by: soni2926 | last post by:
Hi, I have a pop up window, that window needs to refresh the parent window when opened, I'm doing the following: window.opener.location.href(window.opener.location.href); problem I'm having...
5
by: asadhkhan | last post by:
I have the following code which works correctly in IE 6, but in IE 7, Fire Fox 2.0 and Netscape 8 it does not work. I have a main page where a button calls this pop-up and uploads a file once you...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.