473,398 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

make window not pop to back


Hi,

When I run the following html file on netscape, and the button is
clicked, the new window pops BEHIND all my other windows.

How can I easily fix this html file so the window comes up in front
(like a standard alert window would) ?

Thanks. /Eric

Here's the html file (feel free to copy-paste it to try it) :

<html><head><script><!--
function showWin() {
var popWin=window.open("","Pop","width=600,height=100, resizable=yes");
var hh="<HTML><HEAD><TITLE>Answer</TITLE></HEAD>";
hh+="<BODY><form><textarea cols=30 rows=3>You may highlight or edit";
hh += "</textarea></form></BODY></HTML>";
popWin.document.write(hh);
popWin.document.close();
}
// --></script></head><button type=button
onmousedown='showWin();'>Press to create popup window</button></html>

Jul 20 '05 #1
3 5183
Eric Osman wrote:

Hi,

When I run the following html file on netscape, and the button is
clicked, the new window pops BEHIND all my other windows.

How can I easily fix this html file so the window comes up in front
(like a standard alert window would) ?


Page below tested under Moz 1.3. Modifications include closing the
answer window if it is already open and getting the onload event of the
answer window to call focus. Simple call from onload didn't work, so
decoupled event processing through a timer. Tested in Moz only - would
need to test in more browsers before hitting the web :)

HTH
Dom
============

<html><head><script><!--

var popWin;
function showWin() {
if(popWin&&!popWin.closed)
popWin.close();
popWin=window.open("","Pop","width=600,height=100, resizable=yes");

var hh="<HTML><HEAD><TITLE>Answer</TITLE>";
hh+='<script type="text/javascript">';
hh+='function raise(){self.focus();}';
hh+='function decouple(){setTimeout("raise()",50);}';
hh+='window.onload=decouple;<\/script>';
hh+="</HEAD>";

hh+="<BODY><form><textarea cols=30 rows=3>You may highlight or edit";
hh += "</textarea></form></BODY></HTML>";
popWin.document.write(hh);
popWin.document.close();
}
// --></script></head><button type=button
onmousedown='showWin();'>Press to create popup window</button></html>

Jul 20 '05 #2
"Eric Osman" <er*******@rcn.com> wrote in message
news:3F**************@rcn.com...

Hi,

When I run the following html file on netscape, and the button is
clicked, the new window pops BEHIND all my other windows.

How can I easily fix this html file so the window comes up in front
(like a standard alert window would) ?

Thanks. /Eric

Here's the html file (feel free to copy-paste it to try it) :

<html><head><script><!--
function showWin() {
var popWin=window.open("","Pop","width=600,height=100, resizable=yes");
var hh="<HTML><HEAD><TITLE>Answer</TITLE></HEAD>";
hh+="<BODY><form><textarea cols=30 rows=3>You may highlight or edit";
hh += "</textarea></form></BODY></HTML>";
popWin.document.write(hh);
popWin.document.close();
}
// --></script></head><button type=button
onmousedown='showWin();'>Press to create popup window</button></html>

Ah! Hope this helps you... I'm a newbie at javascript and I save some
responses to disk that I think I might want to use at some point... read the
post below (I think by a chap called Grant Wagner) and I hope it makes some
sense to you...
randelld

Grettings:
I have a website where clicking on an image will spawn a pop-up window
that will show a larger version of the image. However, if the user
clicks on an image, it pops up in its own new browser window, and then
the user clicks on the old browser window, the new pop-up window will
revert back to the background and no window will pop-up if the user
clicks on a new image. I know that I am bombarded with pop-ups
everytime I search the web. Some of these pop-ups just run in the
background and I only see them after I have closed all of my other
browser windows. Is there a reverse of this? Can I embed some code in
the onload event to bring the pop-up browser window to the top if the
page reloads with a different image?


Just add an
nameOfPopUpWindow.focus();
to your links.

If you want to be nasty (which you do not want to be, of course), you can
put a

nameOfPopUpWindow.onblur="nameOfPopUpWindow.focus( )";


If he puts that, nothing will happen onblur. Event handlers aren't strings,
they are references (pointers) to functions.

nameOfPopUpWindow.onblur = nameOfPopUpWindow.focus;

might do it, but I also have a problem with you saying "nameOfPopUpWindow",
because you don't call the focus() method on a window's name, you call it on
the reference (pointer) to the window.
and your pop up will always remain in the foreground. However, the original window cannot be accessed anymore now.


OP: To make it do what you seem to be asking, make the <body> tag of the
popup
window look like:

<body onload="window.focus();">
<!-- your popup content goes here -->
</body>


Jul 20 '05 #3
Dom Leonard wrote:
Eric Osman wrote:

When I run the following html file on netscape, and the button is
clicked, the new window pops BEHIND all my other windows.

How can I easily fix this html file so the window comes up in front
(like a standard alert window would) ?

[original repeated for cut and paste]

<html><head><script><!--
function showWin() {
var popWin=window.open("","Pop","width=600,height=100, resizable=yes");
var hh="<HTML><HEAD><TITLE>Answer</TITLE></HEAD>";
hh+="<BODY><form><textarea cols=30 rows=3>You may highlight or edit";
hh += "</textarea></form></BODY></HTML>";
popWin.document.write(hh);
popWin.document.close();
}
// --></script></head><button type=button
onmousedown='showWin();'>Press to create popup window</button></html>
Hi Eric, sorry to answer my own post, but my previous response was
bugging me because I hadn't needed to go to such lengths before.

Using your posted code above, there is something very strange about the
BUTTON element behavior in Mozilla - after opening the window, mouse
over and out of the BUTTON element causes button up and down motion as
if processing of the entire click sequence has been disrupted by opening
the window using mousedown. I'm not about to submit a bug report, but
strongly suspect you are looking for workaround code for this behavior.

The first recommendation is to change the event used to call showWin
from onmousedown to onclick. Most of the problems go away immediately,
with the added advantage the user can cancel click action by dragging
the mouse out of the button.

If onmousedown must be retained as the trigger, then changing the BUTTON
element to an INPUT element (leaving type the same) improves things
greatly under Mozilla.

The general observation remains that generating the same page a second
time will not bring it to the front if the user has not closed it since
opened. This is where closing an already opened window, as performed in
the previous post, can be useful.

Hope this is of slightly more use :)
Cheers,
Dom
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: amith | last post by:
Hi, I have a javascript, calendar.js which i use to enable my client to select the date. This calendar pops up on the click of a gif image. But the problem is that this poped up window is not...
40
by: Brian Jorgenson | last post by:
On my web page, I have a few hyperlinks with target frame of _blank. The hyperlink brings up a second window, but everytime I click on thie hperlink, it keeps bringing up a new window and not...
10
by: Marshall Dudley | last post by:
When I do the following line in Netscape, the popup loads as it should, but the parent window usually, but not always, reloads as well. <a href="#"...
10
by: CyberBless | last post by:
I have a page that opens a child window using window.open(...). How do I make so that when that child window opens you cannot get the focus back on the parent window unless you close the child...
3
by: Feng | last post by:
I am debugging my code from VS.Net and need to watch my console.wirteline messages as I run the code. The problem is, as soon as my code starts running in debugging mode, the console window...
0
by: Owen Jenkins | last post by:
Hi, My application allows users to create a new back end for separate purposes. It does this by using Make Table Queries and Indexing via SQL. For example ... sqlString = "SELECT * INTO " &...
4
by: Owen Jenkins | last post by:
Hi, No-one replied to this when I sent it last week. Any bites out there today?? ----- My application allows users to create a new back end for separate purposes. It does this by using Make...
6
by: divya | last post by:
I have a page name edit.asp which should expire immediately .The user cannot open this page directly he has to provide a password for entering this page.thus when the user enters edit.asp , it has...
6
by: SAL | last post by:
Hi, VS2005 post I'm opening a window using the following syntax: Protected Sub lbEstValue_Click(ByVal sender As Object, ByVal e As System.EventArgs)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.