Hello
The window.open method brings my window to the top only if it is new. If
it's being reused, the window does not come to the foreground (with IE 6 it
does).
Is there a new way in Mozilla/Firefox that I can ensure that this
window comes to the top?
Thank you for your help 13 22173
tochiromifune escreveu: Is there a new way in Mozilla/Firefox that I can ensure that this window comes to the top?
Call the focus method "yourWindow.foc us()" :b
--
Jonas Raoni Soares Silva http://www.jsfromhell.com
"Jonas Raoni" <jo********@gma il.com> wrote in
news:11******** **************@ g14g2000cwa.goo glegroups.com: tochiromifune escreveu: Is there a new way in Mozilla/Firefox that I can ensure that this window comes to the top?
Call the focus method "yourWindow.foc us()" :b
This is what I do but the focus method does not work in Firefox. Here is
the code:
function openFromLink(to wn) {
selectedCity = town
theURL = "seetown.php?se lect=" + selectedCity
newWindow = window.open(the URL,"infoWin"," width=800,heigh t=600")
if (window.focus) {
newWindow.focus ()
}
}
This function is implemented this way:
<a href="javascrip t:openFromLink( 'London')">Lond on</a>
The focus works in IE but not in Firefox.
Lee <RE************ **@cox.net> wrote in news:dq******** *@drn.newsguy.c om: tochiromifune said:
This function is implemented this way: <a href="javascrip t:openFromLink( 'London')">Lond on</a>
The focus works in IE but not in Firefox.
It's because you're abusing the javascript: pseudo-protocol. The focus() method is working, but the main window immediately takes focus back as the link is activated.
<a href="seetown.p hp?select=Londo n" onclick="openFr omLink('London' );return false">London</a>
I tried your way but it does not work either. Also I do not understand
what you explain: the link should be activated before the javascript
function is executed...?
tochiromifune wrote : "Jonas Raoni" <jo********@gma il.com> wrote in news:11******** **************@ g14g2000cwa.goo glegroups.com:
tochiromifu ne escreveu:
Is there a new way in Mozilla/Firefox that I can ensure that this window comes to the top?
Make sure that Tools/Options.../Content tab/Advanced... button/Allow
Scripts to:/Raise or lower existing windows checkbox is checked
More on this: http://www.gtalbot.org/Netscape7Sect...seLowerSetting Call the focus method "yourWindow.foc us()" :b This is what I do but the focus method does not work in Firefox. Here is the code:
function openFromLink(to wn) { selectedCity = town
Why create an extra local variable?
theURL = "seetown.php?se lect=" + selectedCity newWindow = window.open(the URL,"infoWin"," width=800,heigh t=600")
You first need to check the existence of the window reference and its
closed prroperty.
if (window.focus) { newWindow.focus ()
That's not the correct way to call the focus() command. If the window is
new, then, as you say yourself, you do not need to make the focus()
call. On the other hand, if the window exists and if the url is the same
(and you have to check, verify this first, to begin with), then you must
make the focus call on the window reference.
For a practical and recommendable example on all this, see http://developer.mozilla.org/en/docs...Best_practices
and see the example where a single secondary window is used and where
such single secondary window is reused for other links.
} }
This function is implemented this way: <a href="javascrip t:openFromLink( 'London')">Lond on</a>
"javascript :" pseudo-protocol links are widely known to cause all kinds
of problems and are not recommendable. http://jibbering.com/faq/#FAQ4_24 http://developer.mozilla.org/en/docs.....29.22_....3E The focus works in IE but not in Firefox.
It does work in Fx if you allow "Raise or lower existing windows" and if
your code acts accordingly. http://developer.mozilla.org/en/docs/DOM:window.open
Gérard
--
remove blah to email me
Gérard Talbot wrote: tochiromifune wrote : function openFromLink(to wn) { selectedCity = town Why create an extra local variable?
It would be a global, not local one. There is no reason why besides missing
knowledge; the author should have used the `var' keyword to make it local:
function ...(...)
{
var selectedCity = town;
}
One valid reason to copy an argument's value this way is to modify the value
but use the argument's original value later. However, that does not happen
here; so the line is redundant, indeed. theURL = "seetown.php?se lect=" + selectedCity newWindow = window.open(the URL,"infoWin"," width=800,heigh t=600")
You first need to check the existence of the window reference and its closed prroperty.
Absolutely true. And `theURL' and `newWindow' should be declared locals
(at least `theURL' should), where `theURL' is in fact redundant:
var newWindow = window.open(
"seetown.php?se lect=" + selectedCity,
"infoWin",
"width=800,heig ht=600");
This is of course still potentially harmful: there is no guarantee that the
window can be opened with that dimensions or that they make sense anyway.
Especially, the new window would lack scrollbars and the feature of
resizability which in combination is certainly a Bad Thing. And all URI
components should be properly escaped. So I propose
function isMethodType(s)
{
return (s == "function" || s == "object");
}
var esc = (isMethodType(t ypeof encodeURICompon ent)
? encodeURICompon ent
: (isMethodType(t ypeof escape)
? escape
: function(s) { return s; }));
var newWindow = window.open(
"seetown.php?se lect=" + esc(selectedCit y),
"infoWin",
"resizeable,scr ollbars");
instead. The size of the new window is determined by the UA, which should
follow what the user configured; it is resizable by the user and has
scrollbars in case the dimensions of the desktop do not suffice for the
user to resize the window large enough. And the URI component is properly
escaped. if (window.focus) { newWindow.focus ()
That's not the correct way to call the focus() command.
Actually, it is a method that is called. And it is a way I would consider
to be correct (it is not logical to assume that if one Window object has
the `focus' property, another, newly created one, would have not -- or have
you empirical proof of the opposite?), although the feature test allows for
improvement.
I would write
if (newWindow
&& !newWindow.clos ed
&& isMethodType(ty peof newWindow.focus ))
{
newWindow.focus ();
}
If the window is new, then, as you say yourself, you do not need to make the focus() call.
Not true. If there was already a window with the same name ("infoWin"),
its content only has changed due to window.open() but it is unlikely to be
focused already. So it is a Good Thing to try to set the focus to it.
PointedEars
Thomas 'PointedEars' Lahn wrote : Gérard Talbot wrote:
tochiromifune wrote : function openFromLink(to wn) { selectedCity = town Why create an extra local variable?
It would be a global, not local one. There is no reason why besides missing knowledge; the author should have used the `var' keyword to make it local:
function ...(...) { var selectedCity = town; }
One valid reason to copy an argument's value this way is to modify the value but use the argument's original value later. However, that does not happen here;
So why bring this up in your reply then?
so the line is redundant, indeed.
So, according to you, creating an extra variable - oh yeah, a *_local_*
one - in the OP's case was unneeded, pointless, right? theURL = "seetown.php?se lect=" + selectedCity newWindow = window.open(the URL,"infoWin"," width=800,heigh t=600") You first need to check the existence of the window reference and its closed prroperty.
Absolutely true. And `theURL' and `newWindow' should be declared locals (at least `theURL' should), where `theURL' is in fact redundant:
var newWindow = window.open( "seetown.php?se lect=" + selectedCity, "infoWin", "width=800,heig ht=600");
This is of course still potentially harmful: there is no guarantee that the window can be opened with that dimensions or that they make sense anyway. Especially, the new window would lack scrollbars and the feature of resizability which in combination is certainly a Bad Thing. And all URI components should be properly escaped. So I propose
function isMethodType(s) { return (s == "function" || s == "object"); }
var esc = (isMethodType(t ypeof encodeURICompon ent) ? encodeURICompon ent : (isMethodType(t ypeof escape) ? escape : function(s) { return s; }));
var newWindow = window.open( "seetown.php?se lect=" + esc(selectedCit y), "infoWin", "resizeable,scr ollbars");
It's "resizable" , not "resizeable ". If you write "resizeable ", then the
new window will not be resizable.
instead. The size of the new window is determined by the UA, which should follow what the user configured; it is resizable by the user and has scrollbars in case the dimensions of the desktop do not suffice for the user to resize the window large enough. And the URI component is properly escaped.
if (window.focus) { newWindow.focus () That's not the correct way to call the focus() command.
Actually, it is a method that is called.
Useless nitpicking, just nit-picking on semantic.
And it is a way I would consider to be correct (it is not logical to assume that if one Window object has the `focus' property, another, newly created one, would have not -- or have you empirical proof of the opposite?), although the feature test allows for improvement.
I would write
if (newWindow && !newWindow.clos ed && isMethodType(ty peof newWindow.focus )) { newWindow.focus (); }
This kind of code (complete code, complete example) was already provided
at the url I mentioned in my earlier post. Your reply brings very little. If the window is new, then, as you say yourself, you do not need to make the focus() call.
Not true. If there was already a window
Read yourself what's up there. I say "If the window is new" and your
answer/reply starts with "If there was already a window". We're not
talking about the same thing.
Gérard
Gérard Talbot wrote: Thomas 'PointedEars' Lahn wrote : Gérard Talbot wrote: tochiromifune wrote : function openFromLink(to wn) { selectedCity = town Why create an extra local variable? It would be a global, not local one. There is no reason why besides missing knowledge; the author should have used the `var' keyword to make it local:
function ...(...) { var selectedCity = town; }
One valid reason to copy an argument's value this way is to modify the value but use the argument's original value later. However, that does not happen here;
So why bring this up in your reply then?
Because it is important to know that it is not needless always. so the line is redundant, indeed.
So, according to you, creating an extra variable - oh yeah, a *_local_* one - in the OP's case was unneeded, pointless, right?
I eventually confirmed your assessment of that line, no longer considering
the wrong term you used, yes.
[...] var newWindow = window.open( "seetown.php?se lect=" + esc(selectedCit y), "infoWin", "resizeable,scr ollbars"); It's "resizable" , not "resizeable ". If you write "resizeable ", then the new window will not be resizable.
True.
[...] if (window.focus) { newWindow.focus () That's not the correct way to call the focus() command. Actually, it is a method that is called.
Useless nitpicking, just nit-picking on semantic.
No, it is important to know your terms. A method is always associated
with an object; a command is not. Commands are executed, not called.
And it is a way I would consider
Please learn to quote, especially trim your quotes to the
_minimum_ required to retain context.
<URL:http://jibbering.com/faq/faq_notes/pots1.html#ps1P ost> to be correct (it is not logical to assume that if one Window object has the `focus' property, another, newly created one, would have not -- or have you empirical proof of the opposite?), although the feature test allows for improvement.
I would write
if (newWindow && !newWindow.clos ed && isMethodType(ty peof newWindow.focus )) { newWindow.focus (); }
This kind of code (complete code, complete example) was already provided at the url I mentioned in my earlier post. Your reply brings very little.
My reply includes a quite reliable feature test, an important cornerstone in
reliable DOM scripting; the examples you provided the URL for do not (yet). If the window is new, then, as you say yourself, you do not need to make the focus() call.
Not true. If there was already a window
Read yourself what's up there. I say "If the window is new" and your answer/reply starts with "If there was already a window". We're not talking about the same thing.
You can _never_ be sure that a window is new, and the source code provided
by the OP does not indicate it has to be. In fact, the OP's problem was
that the window was _not_ new which is why he wanted to focus the changed
one. You misunderstood.
PointedEars
Thomas 'PointedEars' Lahn wrote : Gérard Talbot wrote:
Thomas 'PointedEars' Lahn wrote : Gérard Talbot wrote: tochiromifune wrote : > function openFromLink(to wn) { > selectedCity = town Why create an extra local variable? It would be a global, not local one. There is no reason why besides missing knowledge; the author should have used the `var' keyword to make it local:
function ...(...) { var selectedCity = town; }
One valid reason to copy an argument's value this way is to modify the value but use the argument's original value later. However, that does not happen here; So why bring this up in your reply then?
Because it is important to know that it is not needless always.
so the line is redundant, indeed. So, according to you, creating an extra variable - oh yeah, a *_local_* one - in the OP's case was unneeded, pointless, right?
I eventually confirmed your assessment of that line, no longer considering the wrong term you used, yes.
[...] var newWindow = window.open( "seetown.php?se lect=" + esc(selectedCit y), "infoWin", "resizeable,scr ollbars"); It's "resizable" , not "resizeable ". If you write "resizeable ", then the new window will not be resizable.
True.
[...]> if (window.focus) { > newWindow.focus () That's not the correct way to call the focus() command. Actually, it is a method that is called. Useless nitpicking, just nit-picking on semantic.
No, it is important to know your terms. A method is always associated with an object; a command is not. Commands are executed, not called.
It is always better to use terms at their best but I won't report or
annoy the poster unless such misuse is important or has important
misunderstandin g consequences. Here, it definitely was not. You, Thomas
Lahn, you do this all the time, regardless of context. You can't expect
people nor demand to people to write perfect english in a javascript
newsgroup, like writing a revised+proofre ad javascript book.
Your nitpicking habits are not necessarly constructive; I'd say they are
more annoying than anything. And your own website is not a model of the
kind of preaching + relentless nitpicking that you practice either. You
have been one of the most vocal person in this newsgroup during years in
blatant and complete contradiction in an embarassing number of areas
(markup validation failures, use of frames, deprecated attributes,
etc.). You demand and have been demanding to others what you haven't
been doing yourself during years. You annoy people with details and
minor issues when your own website has been a failure in large areas.
You've been telling people during years (and you still do) to replace
language="javas cript" with type="text/javascript" in this newsgroup but
you can not and could not even do it on your own website during years!
You tell people very often to learn how to quote, how to use google, how
to do this or that but the thing is you do not even code the way you
demand others to code.
Gérard
--
remove blah to email me
Gérard Talbot <ne***********@ gtalbot.org> wrote:
$ telnet -- mail.gtalbot.or g smtp
| Trying 67.15.2.61...
| Connected to mail.gtalbot.or g.
| Escape character is '^]'.
| 220 srv19.shieldhos t.com ESMTP Sendmail Secured/EZSM; Thu, 12 Jan 2006
| 13:54:23 -0600
| [...]
| RCPT TO:<ne********* **@gtalbot.org>
| 550 5.1.1 <ne***********@ gtalbot.org>... User unknown
| RCPT TO:<ne*******@g talbot.org>
| 559 5.7.1 Message from [...] rejected - see http://njabl.org/ [flame]
<URL:http://www.zedat.fu-berlin.de/services/rules.html>
[x] ab***@uni-berlin.de
[x] Score adjusted
[x] Followup-to: poster
PointedEars This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jiri Brada |
last post by:
Hi,
I have got a following problem with using Javascript:
I have a HTML page with pictures' thumbnails. After clicking on any
thumbnail, I would like to open a new window with the original size
picture. In the main window with thumbnails, I have got following
important stuff:
<SCRIPT LANGUAGE="JavaScript">
|
by: Dominic Tocci |
last post by:
I'm searching for a way to use window.open on my web page to open a window
in firefox that allows the sidebars to work (bookmarks, history, etc).
When I use the following:
var
popWindow=window.open('http://www.yahoo.com','','width=600,height=400,toolbar=1,location=1,menubar=1,resizable=1,titlebar=1,directories=1,status=1,scrollbars=1');
the sidebars are disabled. I click on the buttons for bookmarks and history
and they do nothing. I...
|
by: Markus |
last post by:
Hi,
i have this problem:
Sometimes, i can't reproduce, if i click on an small image on the
website, the popup _AND_ an other Tab in firefox open.
Here are the linkcode:
<div align="center">
|
by: Csaba Gabor |
last post by:
Up until a few weeks ago, javascript code like
window.open("http://mydomain.com", "windowName");
would always bring my new or reused window to the top, with focus.
Lately, Firefox (Deer park alpha 2) only brings it to the top if the
window is new. If it's being reused, the window does not come to
the foreground (with IE 6 it does).
Is there a new way in Mozilla/Firefox that I can ensure that this
|
by: len.hartley |
last post by:
Hi,
I am trying to pop-up a window when the user clicks on an image. The
problem is that when the user clicks on the image and the window pops
up OK, but the window underneath also proceeds to the image. The
desired behavior is that when the pop-up is invoked, I want the
underlying window to stay put.
I don't have this problem when I run the code on my local computer but
I do have it when I run the code on geocities.
| |
by: BoBi |
last post by:
Hi,
See the following URL for the concerned page:
http://home.scarlet.be/kenya-belgium/list_2_en/a_kenyan_cat_and_a_belgian_cat.html
Clicking on "Menu" or "Publication" in the right upper corner triggers
the concerned code. In the code:
menuwd = window.open(locurl, 'kenbelmenu',
|
by: arajunk |
last post by:
In Firefox this opens a full size window (maximized) . In IE it opens
the partial window requiring user to click restore (upper right) to
maximize. What am I missing ?
var
infoWindow=window.open('usgsMain.html','USGSwindow','status=no,resizable=yes,scrollbars=yes');
|
by: deBaer |
last post by:
Hi!
For an in-house web application (it will only be deployed on Firefox
browsers with JavaScript turned on), I need to open a preview window
(which needs to be a separate window, even if Firefox is set to open
targeted links in new tabs) and be able to change the preview window's
location.href from the opening window, even after a new page is loaded
into that window.
Is there any way to do that?
|
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...
|
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,...
|
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...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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
| |