By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,952 Members | 1,053 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,952 IT Pros & Developers. It's quick & easy.

opener.location.href multiple times

P: 12
Hi,

I spawn a window, process some information, and then issue opener.location.href to change the location of the parent information. I then close the child window. Works great.

However, if the user then clicks on a link again on the redirected page and repeats the process (ie, processes more information) the opener.location.href does not change the parent window.

All of the same code is getting executed. Can anyone tell me why repetitive opener.location.href's don't work for the same parent window?

If the user does a manual reload of the page between spawning a new child window it works fine.

Thanks.
Feb 17 '09 #1
Share this Question
Share on Google+
5 Replies


acoder
Expert Mod 15k+
P: 16,027
Can you show some of the code or maybe a link?

Explain the exact steps required to reproduce the problem.
Feb 17 '09 #2

P: 12
Sure.

Very simple. I open the window with this:
Expand|Select|Wrap|Line Numbers
  1. <a href="/localFile?withVariables" onclick="window.open(this.href, 'editWindow', 'menubar=no, width=550, height=600, toolbar=no, scrollbars=yes'); return false;">Edit</a>
After I process the data in the popup window I write just this HTML:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. opener.location.href = "/openerScript?someVars#val";
  5. window.close();
  6. </script>
  7. </head>
  8. </html>
So, basically, the original window URL plus I add the # so it jumps to an anchor.

Works great on the first pass. Redirects the parent window to the right URL and jumps to the anchor. However, if you then reclick the edit link (without refreshing the page manually) it will open the popup, process the data and close but NOT redirect the parent window.
Feb 17 '09 #3

acoder
Expert Mod 15k+
P: 16,027
Is this the same page? Try changing the location after page load <body onload> or window.onload...
Feb 18 '09 #4

P: 12
@acoder
Sorry, not sure I understand.

The popup that is redirecting the parent is a different page. The parent gets redirected anytime a form is submitted in the popup and the popup closes (or, at least is supposed to).

The parent window always gets redirected to the same file, but, technically could have a different URL because there is likely to be different variables. Though, perhaps the problem is that it's not reloading because the URL isn't changing? Does a opener.location.href just not refresh the page if it detects it is the same URL as the parent window already has? How do you deal with that if that's the case?
Feb 18 '09 #5

acoder
Expert Mod 15k+
P: 16,027
By page load, I meant after the page has fully loaded. Your code currently changes the location during page load:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. opener.location.href = "/openerScript?someVars#val";
  5. window.close();
  6. </script>
  7. </head>
  8. </html>
Change it to something like:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function changeLoc() {
  5.   opener.location.href = "/openerScript?someVars#val";
  6.   window.close();
  7. }
  8. </script>
  9. </head>
  10. <body onload="changeLoc()">
  11. </body>
  12. </html>
Feb 23 '09 #6

Post your reply

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