473,597 Members | 2,156 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to open new window

Hi!

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

I have something like this:

oNewWindow = new Object();
oNewWindow = open("sonnich.x ls","Qopen","re sizable=yes,scr oll=yes,
status=yes, width=320px, height=470px",t rue);
oNewWindow.focu s();

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

May 16 '06 #1
19 4217
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.clos ed && newwindow.locat ion)
// If we have a popup already open, us it
{
newwindow.locat ion.href = url;
}
else // create a new popup
{
newwindow=windo w.open(url,'nam e','height=' + h + ',width=' + w + ',
menubar=yes location=yes resizable=yes scrollbars=yes' );
if (!newwindow.ope ner) newwindow.opene r = self; // IE hack
}
if (newwindow.focu s) {newwindow.focu s()}
return false;
}

May 16 '06 #2
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.x ls","Qopen","re sizable=yes,scr oll=yes,
status=yes, width=320px, height=470px",t rue);
oNewWindow.focu s();

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.clo sed)
oNewWindow = window.open("so nni ... );
else
oNewWindow.loca tion = 'fathernich.htm ';
oNewWindow.focu s();
function Pop(page) {
if(foo!=null && !foo.closed)
foo=window.open ('','','width=3 20,height=470,s tatus=1,srollba rs=1,resizable= 1')
foo.location=pa ge;
foo.focus();
}

<a href="sonnich.x ls"
onclick="Pop(th is.href); return false;">sonnich </a>

--
Stephane Moriaux et son [moins] vieux Mac
May 16 '06 #3
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.x ls","Qopen","re sizable=yes,scr oll=yes,
status=yes, width=320px, height=470px",t rue);
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.focu s();

If the window does not exist, then it will be created and will be on top
of the opener. So, your oNewWindow.focu s() 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
--
remove blah to email me
May 17 '06 #4
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

May 17 '06 #5
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.c om, 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/ >
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.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 17 '06 #6
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
Sonnich wrote:
Hi!

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

I have something like this:

oNewWindow = new Object();
oNewWindow = open("sonnich.x ls","Qopen","re sizable=yes,scr oll=yes,
status=yes, width=320px, height=470px",t rue);
oNewWindow.focu s();

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


May 17 '06 #7
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
--
remove blah to email me
May 17 '06 #8
Gérard Talbot wrote:
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.


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"

I'll grant that most seem to behave as you describe, though.
May 17 '06 #9
Tony said the following on 5/17/2006 1:42 PM:
Gérard Talbot wrote:
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.


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.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 17 '06 #10

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

Similar topics

18
8826
by: Paul | last post by:
I link to a web site from an Excel spreadsheet. The page i link to is getCookie.asp which sets a cookie then returns back some html which opens a new window, to the same site but a different page (same folder). The cookie is not received. Can someone explain why? I worked around this by adding a cache-control header with a value of no-cache. This fixes the problem. Unfortunately that causes another problem with Internet Explorer...
6
8219
by: Les | last post by:
Hi, I'd like to find out how to use the window.open() script in Fireworks MX. I have posted my question in the Fireworks forum but didn't get any replies. Since it's javascript, maybe someone could help me here...? I'd like to use the window.open() script to open a separate window, because I'd like to hide the menubar and specify the window size as well. So I specify "javascript:window.open(...)" as the HTML link for a hotspot. However,...
10
11211
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
6726
by: David McCulloch | last post by:
The following code opens a new window, but the "resizeTo" doesn't resize it. Why not? (Don't ask why I simply did not open the window with the new size....my original problem was how to open a new window with maximized dimensions!) FYI, I uploaded the same code to: http://tosasoft.com/test/open.htm ========================================
2
3498
by: Samir Pandey | last post by:
Hello, I am using the following javascript code to open a new window. Somehow, IE always opens a new window. It doesn't open target url in the window name given. All i want is, if there is a window "MyWin" already open, then the main window should load the target url in "MyWin" and not open a new window again.
3
24677
by: NeverLift | last post by:
But, if it's not open, I don't want to open it . . . using window.open will open it if it doesn't exist, even if the url in that open is null (the window is then empty -- but it's open). The situation is: A main window opens child windows one at a time as the user requests, each with its own name. The user may click in any child window or the main window to open a summary window, which has a name all windows know. I want to get that...
2
4387
by: Larry R Harrison Jr | last post by:
I have pull-down menus in javascript and I have the code for opening a link in a new window. But I want it to open a full-sized window. I can't figure out the syntax. What I have so far: Menu5_5_1=new Array("'Lonely Church","javascript:window.open ('http://www.photo.net/photodb/photo?photo_id=2640310')","",0,20,300); That works fine, except I can't figure out how to modify it to make it open full-screen.
8
5630
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...
7
3657
by: anthony.turcotte | last post by:
Hi, I've looked for a solution to this problem on google, read posts in this newsgroup and I still haven't found anything that could help me. Here's the scenario. 1. User accesses pageA.html 2. User clicks on menu link to open popup.html 3. pageA.html checks if popup.html is already open. It is not, open
13
3309
by: Geoff Fox | last post by:
I am in the final moments of designing a new website. One of the pages (http://www.auditionfactory.com/samples.php) has four links to show sample work. I would like these links to open new browser windows when clicked. I have found scripts that will allow one to open, and a few that claim to all multiples to be opened, but so far nothing that will allow a user to open multiple new windows as they click to see new samples. Does anyone...
0
7886
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
8381
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
8258
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...
0
6688
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, 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...
1
5847
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
5431
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();...
0
3886
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...
0
3927
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1494
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.