473,811 Members | 2,729 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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><sc ript><!--
function showWin() {
var popWin=window.o pen("","Pop","w idth=600,height =100,resizable= yes");
var hh="<HTML><HEAD ><TITLE>Answe r</TITLE></HEAD>";
hh+="<BODY><for m><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='sh owWin();'>Press to create popup window</button></html>

Jul 20 '05 #1
3 5215
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><sc ript><!--

var popWin;
function showWin() {
if(popWin&&!pop Win.closed)
popWin.close();
popWin=window.o pen("","Pop","w idth=600,height =100,resizable= yes");

var hh="<HTML><HEAD ><TITLE>Answe r</TITLE>";
hh+='<script type="text/javascript">';
hh+='function raise(){self.fo cus();}';
hh+='function decouple(){setT imeout("raise() ",50);}';
hh+='window.onl oad=decouple;<\/script>';
hh+="</HEAD>";

hh+="<BODY><for m><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='sh owWin();'>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><sc ript><!--
function showWin() {
var popWin=window.o pen("","Pop","w idth=600,height =100,resizable= yes");
var hh="<HTML><HEAD ><TITLE>Answe r</TITLE></HEAD>";
hh+="<BODY><for m><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='sh owWin();'>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
nameOfPopUpWind ow.focus();
to your links.

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

nameOfPopUpWind ow.onblur="name OfPopUpWindow.f ocus()";


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

nameOfPopUpWind ow.onblur = nameOfPopUpWind ow.focus;

might do it, but I also have a problem with you saying "nameOfPopUpWin dow",
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><sc ript><!--
function showWin() {
var popWin=window.o pen("","Pop","w idth=600,height =100,resizable= yes");
var hh="<HTML><HEAD ><TITLE>Answe r</TITLE></HEAD>";
hh+="<BODY><for m><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='sh owWin();'>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
12536
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 modal in nature(i do not want the user to go the parent page unless he selects some date in the calendar popup). In the javascript calendar.js he has used window.open() function to pop up the window. i just want to know whether we have any...
40
10845
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 defaulting the the first active window. How do I make a hyperlink point to the active window? I don not want the hyperlink to default to the same page. I do want a second window but only a second window and not multiple pages.
10
11255
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="#" onClick="window.open('/cgi-bin/displayimage.cgi?/store/demo/image.jpg&YOUR+PRODUCT%27<b>S+NAME+GOES', 'fullimage', 'WIDTH=420,HEIGHT=405,status=0')"> The original window should not reload, but is, and I have tested it with both version 4.72 and 7.02, and they both do it. IE does not do it....
10
4318
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 window? Is it even possible?
3
2101
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 ("Output" window) will disappear and it only comes back when the program ends. How do I keep that window up so I can watch the message come out as the program runs? Thanks Feng
0
1274
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 " & TableName & " IN '" & NewDBName & "' FROM " & TableName & " WHERE 1=2;" DoCmd.RunSQL sqlString 'The WHERE 1=2 ensures that no records are copied - only the
4
3270
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 Table Queries and Indexing via SQL. For example ...
6
5128
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 a button EDIT ,which when user clicks directs him to another page (done.asp). Now the problem is that from this page (done.asp) if he clicks on the back button on the toolbar then edit.asp opens.But I don't want it to open It should show page...
6
2074
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) Response.Write("<script>window.open('EstValueHelp.aspx','_help', 'width=400,height=400');</script>") End Sub
0
9734
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9607
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10652
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10395
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10137
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7673
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5700
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4346
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 we have to send another system
2
3874
muto222
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.