PDA

View Full Version : Opening windows using javascript


shashgo
09-27-2002, 11:18 AM
Hi all,

Im trying to learn javascript, and I need some help. When you open a new window in javascript, with the window.open() statement, what are all the variables that specify the window properties? Example
window.open("somepage.htm","windowname","configuration properties");

What would be the different values for the configuration properties? I onlyknow of height, width, toolbar,menubar,scrollbars.

And is it necessary to assign a variable to the window? Example
var win=window.open('','');

Lastly, when is the window variable name (newWin) and when is the window name(winName) used? Example
var newWin=window.open('me.htm','winName');

HZR
09-27-2002, 01:53 PM
Check this: http://www.pageresource.com/jscript/jwinopen.htm

Also, if you want to create a new window from a link, you should do somethig like this:

<a href="http://evrsoft.com" onclick="window.open(this.href, 'name', 'width=100,height=100,scrollbars,resizable'); return false;">Evrsoft</a>

Josh
09-27-2002, 10:31 PM
here configuration properties:
menubar yes/no
toolbar yes/no
location url/no
resizable yes/no
status yes/no
width ??
height ??

-TheDarkEye-
09-27-2002, 10:50 PM
the window name is exactly what it sounds like. a name for the window. whats it used for? controling the window!

Josh
09-27-2002, 10:57 PM
but how?

-TheDarkEye-
09-27-2002, 11:39 PM
var newWindow = window.open("URL", "WindowName");

newWindow is the object that reffers to the window.

WindowName is the name of the window.

imo, the window name isnt all that useful in a lot of cases. in fact, most people just use an empty string for that argument in the open meathod.

Josh
09-27-2002, 11:42 PM
IMO it's useless.It's just a name that can't do anything

HZR
09-28-2002, 03:47 AM
An example: let's say you have a page (page1) which you can open a window (window1) from. If you then want to open another page in the same window (window1) from the page (page1), names can be useful.
In other words - you can control that window from another window.

shashgo
09-28-2002, 08:29 AM
Hi all,

I think I may have figured out what the purpose of the name is as the second parameter of the window.open. Correct me if Im wrong.

I think the var (win) that the windowi is assigned to as in var

win=window.open('','somename');

is used when you want to write statements to the pop up window that is createed by using

win.document.write('blah');

and the name that is given (some in this case) is used for targeting purposes as when you want to open a document in this popup as in

<a href='blah.htm' target='some'>blah</a>

I think this may be the use, but I am not ttoo sure. Could someone verify this?

HZR
09-28-2002, 09:41 AM
Yea, tha's right, but that's what I meant with my previous post;)

shashgo
09-28-2002, 12:41 PM
HZR,

Your post was probably being written just as I was writing mine.

I like this forum, lots of help

Thanks.

-TheDarkEye-
09-28-2002, 01:07 PM
i should hace mentioned this earlier: window names are just like frame names.

Ghandi Eximius
10-02-2002, 05:33 PM
You can get the best window opening scripts around at http://www.dynamicdrive.com

(and window name is so that if the same script is used to open another page, it will open by window name thus not taking over a previously opened window)

hope i helped!..

river kwai
11-01-2002, 04:06 AM
Do we have to key in all this codes everytime we need a link to open a new window. Doesn't First Page provide a more automated method? I am creating thumbnails of photos when clicked will open a new window. I need a more automated method as I have many photos.

DCElliott
11-01-2002, 04:57 AM
Actually River Kwai has pointed out one of the most useful points of having a window handle. You can use a second window to display larger versions of thumbnails, etc,. reusing the same window every time.