473,473 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Popup box without reload when activated from a different url.

6 New Member
I am using the script below on several webpages, to pop up a window where people can order some things. It works well when shifting forth and back between the same page from where it is activated.
But when it is reactivated from another page on the website the popup is reloaded and things written here dissapear. Is there a way to avoid the popup to reload and only come into focus when clicked from another page?

Expand|Select|Wrap|Line Numbers
  1. [  <script type="text/javascript">
  2. //<![CDATA[var foo=null; function focusfoo(){if (foo&&!foo.closed) foo.focus();}
  3. function blurfoo(){ if (foo&&!foo.closed) foo.blur();} //]]>
  4. </script>
  5. <a href="javascript:void(0)" onclick="foo=window.open('popuppage.htm','win4','width=700,height=460,top=11,left=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');return false" onfocus="foo;" onmouseover="focusfoo();"></a>  ]
  6.  
Thank you.
Karsten
Nov 10 '08 #1
7 2922
acoder
16,027 Recognized Expert Moderator MVP
When you change the page, the reference to the pop-up window will be lost. You can use the pop-up window to re-establish it by using window.opener to refer to its parent window.
Nov 10 '08 #2
Kaster
6 New Member
When you change the page, the reference to the pop-up window will be lost. You can use the pop-up window to re-establish it by using window.opener to refer to its parent window.
Can´t make it work. How should I put it? Tried ....

Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:void(0)" onclick="foo=window.open('popuppage.htm','win4','width=700,height=460,top=11,left=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');return false" window.opener="parent();" onmouseover="focusfoo();"></a>
....and...

Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:void(0)" onclick="foo=window.open('popuppage.htm','win4',window.opener='parent','width=700,height=460,top=11,left=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');return false" onmouseover="focusfoo();"></a>
......but they still reload the popup box.
Thanks again.
Karsten
Nov 11 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
window.opener would be used from the popup window, not from the parent. One idea is to periodically check the parent for a reference to the popup using setInterval. If it doesn't exist, reset the variable foo to the popup window.
Nov 11 '08 #4
Kaster
6 New Member
window.opener would be used from the popup window, not from the parent. One idea is to periodically check the parent for a reference to the popup using setInterval. If it doesn't exist, reset the variable foo to the popup window.
I don´t know how to write this Acoder. I have rewritten the script to look like this:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. //<![CDATA[
  3. function pop() { 
  4. if (!foo) 
  5. foo=window.open('boks.htm','win4','width=700,height=460,top=11,left=300,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes'); 
  6. else foo.focus(); 
  7. var foo=null; function focusfoo(){if (foo&&!foo.closed) foo.focus();}
  8. function blurfoo(){ if (foo&&!foo.closed) foo.blur();} 
  9. //]]></script>
  10.  
  11. <a href="boks.htm" target="boks" 
  12. onclick="pop();return false" onMouseOver="focusfoo()";>Stil spørgsmål til os.</a>
You can see it in function http://es-masseovne.dk/side1.htm

When clicked and reclicked from the same page, it does not reload the pop. But when the same link is clicked from other page the popupform is still reloaded (reset).

Karsten
Nov 18 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
You need to add code in the pop-up window, not the parent window to allow the parent to re-establish the reference.

For example:
Expand|Select|Wrap|Line Numbers
  1. setInterval(testFoo,5000); // every five seconds
  2. function testFoo() {
  3.     if (!window.opener.foo) {
  4.         window.opener.foo = self;
  5.     }
  6. }
Haven't tested, but just an idea.
Nov 18 '08 #6
Kaster
6 New Member
You need to add code in the pop-up window, not the parent window to allow the parent to re-establish the reference.

For example:
Expand|Select|Wrap|Line Numbers
  1. setInterval(testFoo,5000); // every five seconds
  2. function testFoo() {
  3.     if (!window.opener.foo) {
  4.         window.opener.foo = self;
  5.     }
  6. }
Haven't tested, but just an idea.
Acoder you rock!
It did the trick. Thanks a lot, I appreciate your great assitance.
Karsten :-))))))
Nov 20 '08 #7
acoder
16,027 Recognized Expert Moderator MVP
You're welcome. Glad it worked.

PS. You may also want to add a check for window.opener in case the parent window has been closed (unless you close the child window when the parent is closed).
Nov 20 '08 #8

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

Similar topics

21
by: Eugene | last post by:
Hi.... I have a little javascript popup box that people click on to open up an information panel. I made some little blinking star anims on the page that stop blinking after the popup has...
5
by: Hemanth | last post by:
Hello there, I'm running a script that opens a popup window (which is basically a form with checkboxes and a submit button). When I click the submit button I want to run a PHP script and target...
6
by: mkobus | last post by:
Im relatively new, so please be patient with me... I need to update a parent .aspx screen from a popup and close the popup. Normally I would use...
1
by: JJ | last post by:
Hi All, How in ASP.NET, from PopUp window: 1) - save Data in Database; and after 2) a) - Reload the opener window b) -close PopYp window. Note:
1
by: jeffrobbins | last post by:
Hello, I am having an issue that I haven't been able to find an answer for. Any help or pointers to information would be appreciated. I have a form, lets call it mainForm, that contains a...
11
by: Alex.Svetos | last post by:
Hello, I'm trying to get a popup to keep focus when it is re-clicked. The script below is supposed to produce this exact behaviour, however it doesn't work, at least on firefox 1.0.7 and moz...
3
by: Opa | last post by:
Hi , I have a form with javasript which launches a popup via the showModalDialog() method. I get the dialog to open, now I am trying to first get a reference to the calling form from the popup...
10
by: Carlos Araya | last post by:
I have the following link on a web page <p class="menuitem"><a href="#" onclick="loadFragment('http://rivendellweb.net/fortress/home', 'index')" title="The Fortress Home">The Fortress...
1
by: Raffi | last post by:
Hi, I have an application where a link in an iframe in the main page opens a popup with another iframe. This popup iframe has links which when clicked should reload the main page and/or the...
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...
1
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.