Re: Problem with window.open in Firefox
- From: Gérard Talbot <newsblahgroup@xxxxxxxxxxx>
- Date: Thu, 12 Jan 2006 01:16:14 -0500
Thomas 'PointedEars' Lahn wrote :
Gérard Talbot wrote:
tochiromifune wrote :Why create an extra local variable?function openFromLink(town) { selectedCity = town
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?select=" + selectedCity newWindow = window.open(theURL,"infoWin","width=800,height=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?select=" + selectedCity,
"infoWin",
"width=800,height=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(typeof encodeURIComponent) ? encodeURIComponent : (isMethodType(typeof escape) ? escape : function(s) { return s; }));
var newWindow = window.open( "seetown.php?select=" + esc(selectedCity), "infoWin", "resizeable,scrollbars");
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.
That's not the correct way to call the focus() command.if (window.focus) { newWindow.focus()
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.closed && isMethodType(typeof 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 .
- Follow-Ups:
- Re: Problem with window.open in Firefox
- From: Thomas 'PointedEars' Lahn
- Re: Problem with window.open in Firefox
- References:
- Problem with window.open in Firefox
- From: tochiromifune
- Re: Problem with window.open in Firefox
- From: Jonas Raoni
- Re: Problem with window.open in Firefox
- From: tochiromifune
- Re: Problem with window.open in Firefox
- From: Gérard Talbot
- Re: Problem with window.open in Firefox
- From: Thomas 'PointedEars' Lahn
- Problem with window.open in Firefox
- Prev by Date: Re: Grab Data Displayed On Other Web Page Using document.write
- Next by Date: Re: Animated GIF won't work on IE6
- Previous by thread: Re: Problem with window.open in Firefox
- Next by thread: Re: Problem with window.open in Firefox
- Index(es):
Relevant Pages
|