# Java pop up Refreash

**URL:** <https://forum.kirupa.com/t/java-pop-up-refreash/7975>\
**Category:** programming\
**Created:** [November 11, 2002, 7:09pm UTC](https://forum.kirupa.com/t/java-pop-up-refreash/7975 "2002-11-11T19:09:48Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![waffe](https://avatars.discourse-cdn.com/v4/letter/w/c37758/32.png) [@waffe](https://forum.kirupa.com/u/waffe)\
**Post date:** [November 11, 2002, 7:09pm UTC](https://forum.kirupa.com/t/java-pop-up-refreash/7975/1 "2002-11-11T19:09:48Z")

</div>

I am using the java pop up code here at Kirupa. All works well in poping open a single window. The problem is I need to open different pop up windows as needed. My 1st thought was to use a javaclose window command, but thought that might slow things down. How about a way to refreash the already popped up window with the new url.

Is this possible?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2002, 7:17pm UTC](https://forum.kirupa.com/t/java-pop-up-refreash/7975/2 "2002-11-11T19:17:09Z")

</div>

In your javascript code to open the window… make sure the window name is always the same on each link.

It will then load the new page in the same window.

All the windows MUST be the same size though, because the already opened window will not accept the new width and height, I believe you will need to add a resizeTo in the actual HTML page you are load, not sure if that would work though.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2002, 7:55pm UTC](https://forum.kirupa.com/t/java-pop-up-refreash/7975/3 "2002-11-11T19:55:03Z")

</div>

This is the only code I have for poping open my window.

on (press) {  
// customize the window that gets opened  
// 0 equals NO.  
// 1 equals YES.  
address = “[http://www.theweb.asp?index="+listbox.getSelectedItem().data["ID](http://www.theweb.asp?index=%22+listbox.getSelectedItem().data%5B%22ID)”];  
target\_winName = “win”;  
width = 425;  
height = 340;  
toolbar = 0;  
location = 0;  
directories = 0;  
status = 0;  
menubar = 0;  
scrollbars = 0;  
resizable = 0;  
// sends data back to the function  
openWinCentre(address, target\_winName, width, height, toolbar, location, directories, status, menubar, scrollbars, resizable);  
}

So I only have one button that pops open a new window. As the code stands when I hit the button to open a new window the same window pops to the front with the same url/ID.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2002, 8:01pm UTC](https://forum.kirupa.com/t/java-pop-up-refreash/7975/4 "2002-11-11T20:01:00Z")

</div>

Well you definitely have to change your script :-\

I have attached a .txt file in this post and my next post to show you 2 different methods of making pop-up windows where you can have more than just one link 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2002, 8:01pm UTC](https://forum.kirupa.com/t/java-pop-up-refreash/7975/5 "2002-11-11T20:01:22Z")

</div>

And here is the second method… I prefer this one.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2002, 8:14pm UTC](https://forum.kirupa.com/t/java-pop-up-refreash/7975/6 "2002-11-11T20:14:06Z")

</div>

A few nights ago we worked on trying to use java pop up commands and passing a query string at the same time.  
The Thread is called “java pop up + string query”

It would’t work so you directed me to the Kirupa code that I am using now to pop open the window.

How about this, is there a way to close the window I opened before I open a new window?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2002, 8:16pm UTC](https://forum.kirupa.com/t/java-pop-up-refreash/7975/7 "2002-11-11T20:16:52Z")

</div>

Oh yea… please forgive my lapse of memory.

You could try this…

```auto
on (press) {
// customize the window that gets opened
// 0 equals NO.
// 1 equals YES.
address = "http://www.theweb.asp?index="+listbox.getSelectedItem().data["ID"];
<B>address2 = "http://www.theweb.asp?index="+listbox.getSelectedItem().data["ID"];</B>
target_winName = "win";
width = 425;
height = 340;
toolbar = 0;
location = 0;
directories = 0;
status = 0;
menubar = 0;
scrollbars = 0;
resizable = 0;
// sends data back to the function
openWinCentre(address, target_winName, width, height, toolbar, location, directories, status, menubar, scrollbars, resizable);
<B>openWinCentre2(address, target_winName, width, height, toolbar, location, directories, status, menubar, scrollbars, resizable);</B>
}

```

That gives you a second address to use, and a second function to call it from.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2002, 9:18pm UTC](https://forum.kirupa.com/t/java-pop-up-refreash/7975/8 "2002-11-11T21:18:37Z")

</div>

No change in performence. So how can I close the pop up window I have opened?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2002, 9:19pm UTC](https://forum.kirupa.com/t/java-pop-up-refreash/7975/9 "2002-11-11T21:19:55Z")

</div>

untested but I am guess winName.close();

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2002, 9:41pm UTC](https://forum.kirupa.com/t/java-pop-up-refreash/7975/10 "2002-11-11T21:41:02Z")

</div>

on (press) {  
winName.close();  
}

on (release) {  
//customize the window that gets opened  
// 0 equals NO.  
// 1 equals YES.  
address = “[http://www.theweb.asp?index="+listbox.getSelectedItem().data["ID](http://www.theweb.asp?index=%22+listbox.getSelectedItem().data%5B%22ID)”];  
target\_winName = “win”;  
width = 425;  
ect…

I also tried  
on (press) {  
winName.close(win);  
}  
ect…

on (press) {  
target\_winName.close();  
}  
ect…

Nothing worked.  
Do you have any more bullets.😛

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2002, 10:44pm UTC](https://forum.kirupa.com/t/java-pop-up-refreash/7975/11 "2002-11-11T22:44:52Z")

</div>

```php

on (press) {
	getURL ("javascript:myWin.close()");
}

```

that should work with the code provided at the tutorial.

[EDIT]  
remove the space between java and script to look like this: javascript

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2002, 11:29pm UTC](https://forum.kirupa.com/t/java-pop-up-refreash/7975/12 "2002-11-11T23:29:00Z")

</div>

One last question on this subject.

You have

on (press) {  
getURL (“javascript:myWin.close()”);  
}

Which works perfectly, but why is it not

on (press) {  
getURL (“javascript:Win.close()”);

Since target\_winName = “win”; is in my code?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 12, 2002, 12:09am UTC](https://forum.kirupa.com/t/java-pop-up-refreash/7975/13 "2002-11-12T00:09:13Z")

</div>

well… I’m not pretty good explaining how the codes work.  
even more… I’m not good explaining anything.  
that’s why I’ll never write any tutorial :-\

but I could give it a try:

lets say that you have to give a name to every function you want to perform. in this case it was **myWin**.

> 

getURL (“javascript:var **myWin** ; if(! **myWin** || **myWin**.closed){ **myWin** = window.open('” + url + … bla bla bla … + “,top='+((screen.height/2)-(” + h/2 + “))+‘,left=’+((screen.width/2)-(” + w/2 + “))+'” + “')}else{ **myWin**.focus();};void(0);”);  
}

as far as I know flash can’t open or close any window by itself… it has to be done through javascript. and the way to use javascript in flash is with **getURL**

now… why you can’t use the code like you said? that’s because we don’t have any function (window) called **Win**.

does that make any sense? ☹

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 16, 2002, 6:54pm UTC](https://forum.kirupa.com/t/java-pop-up-refreash/7975/14 "2002-11-16T18:54:25Z")

</div>

HI

Thanks for the explanation it makes sense well enough to get by:) I have a new problem with the close command, on some computers you get a warning message stating “windows is about to close a window, do you want to do this, YES-NO.”

What setting in IE Internet options makes this happen, none of my computers give the error but for others it does?

And is there any way to stop it from happening all together?

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 17, 2002, 4:35am UTC](https://forum.kirupa.com/t/java-pop-up-refreash/7975/15 "2002-11-17T04:35:46Z")

</div>

well … I’m not sure what causes this  
but I don’t think there’s a way to stop it. not sure either

maybe someone else got the right answer??

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 19, 2002, 8:44pm UTC](https://forum.kirupa.com/t/java-pop-up-refreash/7975/16 "2002-11-19T20:44:13Z")

</div>

Still know luck on stopping the windows warning message, but I’ll let [Kirupa.com](http://Kirupa.com) know if I find anything.

New issue, It has to do with the same code from the tutorial “Launching a Centered Pop-Up Window.” All is fine until I try to use two sets of pop up code in the same scene.

So, I have one line of code and a button to open a music jukebox, and a second line of code and a button to open a photo gallery, all in the same scene.

The problem is, I click on the button to open the jukebox, and then click on the button to open the photo gallery, the photo gallery will not open. If I then close the jukebox and click on the photo gallery button the gallery opens. The same happens in the reverse.

Is there a way to solve this problem?

:nerd:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 21, 2002, 1:40am UTC](https://forum.kirupa.com/t/java-pop-up-refreash/7975/17 "2002-11-21T01:40:12Z")

</div>

use the code you already have for the jukebox  
and this one for your photo gallery

I think you’ll get the point so you can open any number of popups

```auto

on (release) {
	address = "http://www.kirupa.com/modular/pop-up.htm";
	target_winName = "kirupa";
	width = 400;
	height = 300;
	toolbar = 0;
	location = 0;
	directories = 0;
	status = 0;
	menubar = 0;
	scrollbars = 1;
	resizable = 0;
	openWinCentre2(address, target_winName, width, height, toolbar, location, directories, status, menubar, scrollbars, resizable);
}

```

```auto

Movieclip.prototype.openWinCentre2 = function (url, winName, w, h, toolbar, location, directories, status, menubar, scrollbars, resizable) { 
	getURL ("javascript:var myWin2; if(!myWin2 || myWin2.closed){myWin2 = window.open('" + url + "','" + winName + "','" + "width=" + w + ",height=" + h + ",toolbar=" + toolbar + ",location=" + location + ",directories=" + directories + ",status=" + status + ",menubar=" + menubar + ",scrollbars=" + scrollbars + ",resizable=" + resizable + ",top='+((screen.height/2)-(" + h/2 + "))+',left='+((screen.width/2)-(" + w/2 + "))+'" + "')}else{myWin2.focus();};void(0);");
}

```

pretty easily huh?
