# Force window to top

**URL:** <https://forum.kirupa.com/t/force-window-to-top/6817>\
**Category:** programming\
**Created:** [October 17, 2002, 1:48am UTC](https://forum.kirupa.com/t/force-window-to-top/6817 "2002-10-17T01:48:02Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aaron\_Burgess](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@Aaron\_Burgess](https://forum.kirupa.com/u/Aaron_Burgess)\
**Post date:** [October 17, 2002, 1:48am UTC](https://forum.kirupa.com/t/force-window-to-top/6817/1 "2002-10-17T01:48:02Z")

</div>

I would like to know if it’s possible to force a window to the front? I have images load up inside a child window (it resizes to match the images), but when I click on a new image the window stays behind the parent. alwaysRaised doesn’t work on Explorer, infact it doesn’t seem to work that well anywhere.

Does anyone know of a command or script that can force a window to the front?

---

<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:** [October 17, 2002, 2:27am UTC](https://forum.kirupa.com/t/force-window-to-top/6817/2 "2002-10-17T02:27:59Z")

</div>

Oooo, I know this…I know this… why isn’t it coming to me!!!

window.focus() I believe… I will see if I can set up some kind of example…

IT IS ON THE TIP OF MY TONGUE!!!

\<B\>EDIT:\</B\> Can you supply a .zip file with an file so I can work around the script you are using. It would make things much easier.

---

<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:** [October 17, 2002, 2:48am UTC](https://forum.kirupa.com/t/force-window-to-top/6817/3 "2002-10-17T02:48:00Z")

</div>

I think you are right on target…

😛 😛

we’re not worthy…\<i\>makes the bow motion\</i\>

Rev:elderly:

---

<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:** [October 17, 2002, 2:49am UTC](https://forum.kirupa.com/t/force-window-to-top/6817/4 "2002-10-17T02:49:57Z")

</div>

I know it is window.focus()

But my problem is how to implement it into the script. That is what is on the tip of my tongue, but seeing that script he uses will probably help me refresh my memory.

No need to bow rev… and you are fully worthy!

---

<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:** [October 17, 2002, 11:46pm UTC](https://forum.kirupa.com/t/force-window-to-top/6817/5 "2002-10-17T23:46:50Z")

</div>

email on it’s way. 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:** [October 21, 2002, 8:07pm UTC](https://forum.kirupa.com/t/force-window-to-top/6817/6 "2002-10-21T20:07:20Z")

</div>

Hello Boys!  
Is the solution available for me too, I have the same problem!!!

Thank for helping out!!!

---

<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:** [October 21, 2002, 9:45pm UTC](https://forum.kirupa.com/t/force-window-to-top/6817/7 "2002-10-21T21:45:44Z")

</div>

hmmm, depending on your script…

Try something like…

```php

function openWin() {
var newWin = window.open(blah).focus();
}

```

yeah, that is very short and bland, but you should already have the javascript code so I didn’t focus on that, I just focused on the focus() (haha, pun intended).

---

<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:** [October 22, 2002, 6:30am UTC](https://forum.kirupa.com/t/force-window-to-top/6817/8 "2002-10-22T06:30:10Z")

</div>

Thanks, now I know what to do!!!

/ 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:** [October 22, 2002, 6:31am UTC](https://forum.kirupa.com/t/force-window-to-top/6817/9 "2002-10-22T06:31:54Z")

</div>

no problem 🙂

---

<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:** [October 22, 2002, 9:23am UTC](https://forum.kirupa.com/t/force-window-to-top/6817/10 "2002-10-22T09:23:49Z")

</div>

test  
😛

---

<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:** [October 22, 2002, 10:55am UTC](https://forum.kirupa.com/t/force-window-to-top/6817/11 "2002-10-22T10:55:06Z")

</div>

You can force it to the foreground always (sux!) by combining body on load self.focus and  
on kill focus self.focus… not the exact syntax used…

---

<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:** [October 22, 2002, 4:17pm UTC](https://forum.kirupa.com/t/force-window-to-top/6817/12 "2002-10-22T16:17:00Z")

</div>

Well, I don’t believe the onLoad=“self.focus();” KEEPS it at the front. I believe it puts it in the front when the page loads.

Now Modal Dialog Windows stay in the front all the time. But they are incredibly annoying and I am not going to tell anyone how to do them 🙂 :evil:
