how to open new window

S

Sonnich

Hi!

I have used JS, but I am still new to it.

I have something like this:

oNewWindow = new Object();
oNewWindow = open("sonnich.xls","Qopen","resizable=yes,scroll=yes,
status=yes, width=320px, height=470px",true);
oNewWindow.focus();

and I need to make it work so, that it always opens a new window (it is
a function).

I have tried oNewWindow=null, but that does not do it

Sonnich
 
R

Rob

Here's the code I use to popup a new window. It's kind of specific to
my application but you can change it to your specifications. I have
another function, setField, which is called from the popup to return a
value into the "opener" window.

Good luck, Rob:-]


var newwindow = undefined;

// Open popup window. Works with function setField to allow a value to
be returned via "opener"
function popitup(url, width, height)
{
var h = '350';
var w = '300';
if(width && width.length > 0)
w = width;
if(height && height.length > 0)
h = height;
// alert(url); // for debugging
if (newwindow && !newwindow.closed && newwindow.location)
// If we have a popup already open, us it
{
newwindow.location.href = url;
}
else // create a new popup
{
newwindow=window.open(url,'name','height=' + h + ',width=' + w + ',
menubar=yes location=yes resizable=yes scrollbars=yes');
if (!newwindow.opener) newwindow.opener = self; // IE hack
}
if (newwindow.focus) {newwindow.focus()}
return false;
}
 
A

ASM

Sonnich a écrit :
I have something like this:

oNewWindow = new Object();

if you tell oNewWindow is new, of course it is new (window)
oNewWindow = open("sonnich.xls","Qopen","resizable=yes,scroll=yes,
status=yes, width=320px, height=470px",true);
oNewWindow.focus();

and I need to make it work so, that it always opens a new window (it is
a function).

I have tried oNewWindow=null, but that does not do it

simply :
if(oNewWindow!=null && !oNewWindow.closed)
oNewWindow = window.open("sonni ... );
else
oNewWindow.location = 'fathernich.htm';
oNewWindow.focus();


function Pop(page) {
if(foo!=null && !foo.closed)
foo=window.open('','','width=320,height=470,status=1,srollbars=1,resizable=1')
foo.location=page;
foo.focus();
}

<a href="sonnich.xls"
onclick="Pop(this.href); return false;">sonnich</a>
 
G

Gérard Talbot

Sonnich a écrit :
Hi!

I have used JS, but I am still new to it.

Everything you need to know (including syntax and working examples) are
provided at:

http://developer.mozilla.org/en/docs/DOM:window.open
I have something like this:

oNewWindow = new Object();

You do not need to create a new Object().
oNewWindow = open("sonnich.xls","Qopen","resizable=yes,scroll=yes,
status=yes, width=320px, height=470px",true);

1- if the open() method is called, in some cases/context, the method
will link to the document and not to the window object. So, it's better
to always scope the call to the window object.

2- scroll is not a valid windowFeature; scrollbars is.

3- there should be no blank space between windowFeatures

4- width and height take no "px"

5- there is no 4th argument: your "true" argument will be ignored.

6- Note that the referenced resource is a specific content-type which is
supposed to open up MS-Excel if it is installed on the remote ssystem.
You should warn accordingly your users about this.

"You always need to provide an *explicit warning when linking to files
in any other format than HTML* for at least two reasons:
o the user may not have the necessary software installed and it is very
impolite to make them wait (these files are usually bigger than simple
HTML) for something they can't use
o the non-standard file format will cause a non-standard behavior: for
example, a PDF file will start up Acrobat (if the user has it installed,
of course), thus giving users a nasty surprise in terms of an even
longer wait and the appearance of new and different interface controls"
J. Nielsen
Linking to Non-Standard Files Without Warning
http://www.useit.com/alertbox/990530_comments.html


oNewWindow.focus();


If the window does not exist, then it will be created and will be on top
of the opener. So, your oNewWindow.focus() call here is inappropriate.
You should examine the examples at


http://developer.mozilla.org/en/docs/DOM:window.open

for a more judicious/appropriate use of focus().


Gérard
 
A

Adnan Siddiqi

problem with window.open() is that it is blocked by popup blockers.If
you set toolbar=yes then it doesnt ONLY if you click some link manually
otherwise if you set toolbar=yes and simulate onClick event of Anchor
tag then it blocks it anyway and I hae not found remedy for this
disease as yet
 
R

Randy Webb

Adnan Siddiqi said the following on 5/17/2006 2:24 AM:

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

problem with window.open() is that it is blocked by popup blockers.

Precisely. And you know why pop up blockers are so popular?
People do not want pop ups.
If you set toolbar=yes then it doesnt ONLY if you click some link manually

Yes, clicking a link is a user action and typically gets around most pop
up blockers since most just block non user initiated pop ups.
otherwise if you set toolbar=yes and simulate onClick event of Anchor
tag then it blocks it anyway

toolbars=yes doesn't have an impact on that. The firing of the onClick
is not done by the user so it becomes an unwanted pop up.
and I hae not found remedy for this disease as yet

Would that disease be:
a) Inept web authors trying to force new windows on users.
b) People replying in Usenet without quoting what they are replying to.
c) HIV/AIDS
d) All of the Above.
 
S

Sonnich

Hi!

Thanks for the help, but I think I need to explain.

I have list of items, and when the user wants to open something it
happens like this.
But if the user wants to open 3141 window, the user should be allowed
to.

The ideas given here reuses the same window which _is_ my problem - I
need to open item#1 in one window, and when opening item#2 it should
happen in a new window (like target=_blank in HTML).

BR
Sonnich
 
G

Gérard Talbot

Adnan Siddiqi wrote :
problem with window.open() is that it is blocked by popup blockers.

If you open the window automatically, yes. Popup blockers only act on
javascript-initiated windows which opens without any user interaction.

If
you set toolbar=yes then it doesnt ONLY if you click some link manually
otherwise if you set toolbar=yes and simulate onClick event of Anchor
tag then it blocks it anyway

That's not true. toolbar=yes has nothing to do with blocking popups.
Automatically opening windows without any user interaction are
unrequested popup windows and only those are blocked by so-called popup
blockers.

Next time, please quote what you are replying to.

Gérard
 
R

Randy Webb

Tony said the following on 5/17/2006 1:42 PM:
Not completely true. I have encountered at least one that blocks
user-initiated popups (that open when clicking on a link) - it even
blocked target="_blank"

Symantec does about that, without the _blank part, by redefining
window.open. Messy business trying to get around it :)

Simplest solution? Don't try to open new windows - issue solved.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated
Wed, 17 May 2006 03:33:16 remote, seen in
Randy Webb said:
Adnan Siddiqi said the following on 5/17/2006 2:24 AM:

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

<URL: http://www.safalra.com/special/googlegroupsreply/ >


That is a satisfactory page, as far as it goes. The next step, for the
majority of Googlers, is to full-quote (the page is weak on that) and to
top-post (the page says nothing on that).

Better, therefore, from the news-user point of view, to refer explicitly
to c.l.j FAQ section 2.3 paragraphs 6 & 7; that implies that your
request is not some Lahnish bee-in-the-bonnet / bats-in-the-belfry sort
of thing, but corresponds to the general wishes of those likely to give
good answers..

It has the additional advantage of drawing attention to the FAQ, which
may well answer the current or some potential future javascript
question.

<FAQENTRY>
Could refer to http://www.usenet.org.uk/ukpost.html which is RFC-
compatible.
 
R

Randy Webb

Dr John Stockton said the following on 5/17/2006 5:33 PM:
JRS: In article <[email protected]>, dated
Wed, 17 May 2006 03:33:16 remote, seen in


That is a satisfactory page, as far as it goes. The next step, for the
majority of Googlers, is to full-quote (the page is weak on that) and to
top-post (the page says nothing on that).

Assuming you mean bottom post as top posting is explicitly dealt with in
the FAQ:

<quote cite="http://jibbering.com/faq/#FAQ2_3" paragraph 6>
When replying to a message on the group trim quotes of the preceding
messages to the minimum needed and add your comments below the pertinent
section of quoted material, as per FYI28/RFC1855 (never top post).
</quote>

As for full quoting, I don't agree with that either. Quote the minimum
and snip appropriately.
Better, therefore, from the news-user point of view, to refer explicitly
to c.l.j FAQ section 2.3 paragraphs 6 & 7; that implies that your
request is not some Lahnish bee-in-the-bonnet / bats-in-the-belfry sort
of thing, but corresponds to the general wishes of those likely to give
good answers..

The FAQ does not directly relate to the problem of quoting from Google
Groups. And it shouldn't either. If you make an exception for one
posting agent, the FAQ will become an FAQ for posting software.
It has the additional advantage of drawing attention to the FAQ, which
may well answer the current or some potential future javascript
question.

If they don't find the FAQ from my signature, then pointing them to it
explicitly isn't likely to help.
<FAQENTRY>
Could refer to http://www.usenet.org.uk/ukpost.html which is RFC-
compatible.

It could, but shouldn't as that article is specific to how to post to
uk.* newsgroups, not to comp.lang.javascript
 
A

Adnan Siddiqi

Gérard Talbot said:
Adnan Siddiqi wrote :

If you open the window automatically, yes. Popup blockers only act on
javascript-initiated windows which opens without any user interaction.



That's not true. toolbar=yes has nothing to do with blocking popups.
Automatically opening windows without any user interaction are
unrequested popup windows and only those are blocked by so-called popup
blockers.

Next time, please quote what you are replying to.

Gérard
--


Hi

First of all I am sorry ,yes I am using Google frontend for posting in
Usenet and this time i hope i am posting properly?

Speaking of Manual click or raising Click event by script?How does it
make difference?
 
S

Sonnich

No need to quote this

I still have the problem (see other post) and this discussion should be
a new thread.
 
R

Randy Webb

Sonnich said the following on 5/18/2006 8:12 AM:
No need to quote this

If you don't quote, how would anybody with a decent newsreader know what
you are talking about?
I still have the problem (see other post)

Solution to your problem: Don't use a window name.
and this discussion should be a new thread.

What discussion? The one about inept web authors attempting to force new
windows on the end user? Or the discussion you didn't even allude to?
Or, could it be some other discussion?
 
S

Sonnich

Randy said:
Sonnich said the following on 5/18/2006 8:12 AM:

If you don't quote, how would anybody with a decent newsreader know what
you are talking about?

:)
It was sarcastic, also pointing out that this qouting discussion should
be in another thread
Solution to your problem: Don't use a window name.

just like open(ssdgdf)
doesn't work
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated
Wed, 17 May 2006 19:22:55 remote, seen in
Randy Webb said:
Dr John Stockton said the following on 5/17/2006 5:33 PM:

Assuming you mean bottom post as top posting is explicitly dealt with in
the FAQ:

No, I mean exactly what I wrote. You have failed to read it carefully
and/or to think about its meaning. Remember that it's English that I
write in, not American.

<quote cite="http://jibbering.com/faq/#FAQ2_3" paragraph 6>
When replying to a message on the group trim quotes of the preceding
messages to the minimum needed and add your comments below the pertinent
section of quoted material, as per FYI28/RFC1855 (never top post).
</quote>

As for full quoting, I don't agree with that either. Quote the minimum
and snip appropriately.


The FAQ does not directly relate to the problem of quoting from Google
Groups.

Read FAQ section 2.3 paragraphs 6 & 7, of the current (2005-11-05)
version. Para 7 is Google-specific, and explains how to comply with
paragraph 6.

And it shouldn't either. If you make an exception for one
posting agent, the FAQ will become an FAQ for posting software.


If they don't find the FAQ from my signature, then pointing them to it
explicitly isn't likely to help.

Some news-reading agents do not show signatures by default. And most
Google-users are only semi-literate and half-witted; you should realise
that a reference in the main part of the reply is more likely to be
effective.

It could, but shouldn't as that article is specific to how to post to
uk.* newsgroups, not to comp.lang.javascript

Evidently you have not read it with any more than your usual care. Its
purpose is UK-specific; but its substance is not. follows the
Big-8 preference as expressed in the standard documents for netiquette,
but has a properly-elected Committee. Re-read the part of UKpost before
the Table of Contents (I read it in and assume the Web
copy matches closely).


BTW, did I mention my policy of demonstrating, where it's apparently
necessary, aspects of English writing and its grammar/spelling rules?
 
R

Randy Webb

Dr John Stockton said the following on 5/18/2006 4:41 PM:
JRS: In article <[email protected]>, dated
Wed, 17 May 2006 19:22:55 remote, seen in

No, I mean exactly what I wrote. You have failed to read it carefully
and/or to think about its meaning. Remember that it's English that I
write in, not American.

The term you used was "top-post" which means to post at the top. As
compared to bottom posting, neither of which is desired. What is desired
is, for a lack of a better term, interleaved posting.

As for your pedantics about English versus American, I have told you,
repeatedly, that the language is interpretive. What is more important is
what the reader gets from it - no matter what you meant. I would assume
that you, of all people, might understand that but you obviously don't.
Read FAQ section 2.3 paragraphs 6 & 7, of the current (2005-11-05)
version. Para 7 is Google-specific, and explains how to comply with
paragraph 6.

Para 7 is not Google-specific. It does *not* deal with Google Groups
posting, it deals with asking to be emailed a response.

<quote cite="http://jibbering.com/faq/#FAQ2_3" Para 7>
Don't ask, or at least expect, to be emailed individually. Some
individuals run scams for the purpose of collecting active email
addresses and many won't risk being victimized. If you have
circumstances that won't allow you to read clj for the follow-up,
explain what they are and ask to be CC'ed a copy. You also might try
http://groups.google.com/ to read replies.
</quote>

Where in that does it say *anything* about posting from Google Groups
and/or how to properly get Google Groups to quote a post?
Some news-reading agents do not show signatures by default.

Very true.
And most Google-users are only semi-literate and half-witted;

You can't even come close to semi-proving that. That is nothing more
than your bias against anything non-JRS showing through. The only time a
Google poster is noted is when they don't quote. Other than that, unless
you are just a moron with nothing better to do, it is never noticed that
its from a GG poster.
you should realise that a reference in the main part of the reply is
more likely to be effective.

YSCIB. Aside from that, maybe. But, the FAQ is quoted in my signature on
every post I make, I am not going to include it inside every post I
make. If they don't see it in the signature, then they won't see it
elsewhere.

** added there to cut down on some of Richards work when the FAQ finally
gets around to being updated again.
Evidently you have not read it with any more than your usual care.

I don't need to read it and have no desire to read a document that the
Heading on it proclaims it to be a document specific to posting to uk.*
hierarchies. I don't post in those groups so I have no desire to read
anything about it.
Its purpose is UK-specific; but its substance is not.

Read above.
follows the Big-8 preference as expressed in the standard
documents for netiquette, but has a properly-elected Committee.

Re-read the part of UKpost before the Table of Contents (I read it in
news:uk.answers, and assume the Web copy matches closely).

If you can tell me why I should even be remotely interested in a UK
specific document when I am not in the UK - nor do I post to UK groups -
then maybe I will.
BTW, did I mention my policy of demonstrating, where it's apparently
necessary, aspects of English writing and its grammar/spelling rules?

Translation: JRS is pedantic about spelling practices.

Yes, I am aware of your pedantic behavior. Not that I give a rats rear
end though.

But, since you mention things as such, have I mentioned to you (no less
than 5 times) that English is an interpretive language and nothing more
and that is very easy to prove that?
 
G

Gérard Talbot

Sonnich wrote :
:)
It was sarcastic, also pointing out that this qouting discussion should
be in another thread

If you do not want a helpful, useful reply, then do not post an helpful
nor useful post. Simple.

If you do not want assistance to solve whatever problem your webpage may
have, then do not post an meaningful post on that webpage. Easy.

If you do not seek help for whatever problem your webpage may have, then
please do not post a helpful message. Just post a general, abstract
message about an unspecified problem regarding an unknown webpage
occuring in an unidentified context.
just like open(ssdgdf)
doesn't work

Yep! lseo9wekwer jw90re4

Gérard
 
T

Thomas 'PointedEars' Lahn

Sonnich said:
I have used JS, but I am still new to it.
Obviously.

I have something like this:

oNewWindow = new Object();
oNewWindow = open("sonnich.xls","Qopen","resizable=yes,scroll=yes,
status=yes, width=320px, height=470px",true);

There is exactly no point to the first line. What happens here is that you
create a new Object object and assign a reference to it to `oNewWindow',
then mark this new object immediately for garbage collection as you
overwrite the value of `oNewWindow' with a reference to what is supposedly
a Window object or not a reference (assuming that open() calls
window.open(), which is _not_ for sure; so always call window.open()
explicitly).

You should declare `oNewWindow' instead (either globally or locally,
depending on the scope of its use), and the third argument of
(window.)open() must not contain spaces, nor are the feature values
supposed to use CSS lengths, or does that method have a used fourth
argument.
oNewWindow.focus();

You need to test whether open() returned an object, and if that object has a
focus() method.

function isMethod(a)
{
return a && /\b(function|object)\b/.test(typeof a);
}

var oNewWindow = window.open("sonnich.xls", "Qopen",
"resizable,scrollbars,status,width=320,height=470");

if (oNewWindow)
{
if (isMethod(oNewWindow.focus))
{
oNewWindow.focus();
}
}

Be aware that with a smaller desktop a 320x470 pixels sized popup may be
too large to be fully displayed, and therefore security precautions can
enforce the default window size instead.
and I need to make it work so, that it always opens a new window (it is
a function).

The reason why the existing popup is reused is that you use a static name.
Use a dynamic name instead:

var oNewWindow = window.open("sonnich.xls",
"Qopen" + new Date().getTime(),
"resizable,scrollbars,status,width=320,height=470");

Be aware that popup blockers exist, and that without a viewer plugin the
Excel spreadsheet will not be displayed within the Web UA anyway. So even
if the popup is not blocked, you may open several popups with no content
that trigger a download dialog.
I have tried oNewWindow=null, but that does not do it

Of course not. That is only marking the object referred to for garbage
collection, unless there are further references to it. See above.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top