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? - [ <script type="text/javascript">
-
//<![CDATA[var foo=null; function focusfoo(){if (foo&&!foo.closed) foo.focus();}
-
function blurfoo(){ if (foo&&!foo.closed) foo.blur();} //]]>
-
</script>
-
<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> ]
-
Thank you.
Karsten
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.
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 .... - <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... - <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
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.
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: - <script type="text/javascript">
-
//<![CDATA[
-
function pop() {
-
if (!foo)
-
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');
-
else foo.focus();
-
}
-
var foo=null; function focusfoo(){if (foo&&!foo.closed) foo.focus();}
-
function blurfoo(){ if (foo&&!foo.closed) foo.blur();}
-
//]]></script>
-
-
<a href="boks.htm" target="boks"
-
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
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: - setInterval(testFoo,5000); // every five seconds
-
function testFoo() {
-
if (!window.opener.foo) {
-
window.opener.foo = self;
-
}
-
}
Haven't tested, but just an idea.
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: - setInterval(testFoo,5000); // every five seconds
-
function testFoo() {
-
if (!window.opener.foo) {
-
window.opener.foo = self;
-
}
-
}
Haven't tested, but just an idea.
Acoder you rock!
It did the trick. Thanks a lot, I appreciate your great assitance.
Karsten :-))))))
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).
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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:
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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,...
|
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,...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
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 ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |