AlfieWebDevTips Homefor new and experienced developers
[Home Home] [Web Development Web Development ] [Code Generators Code Generators ] [Resources Resources ] [Contact Us Contact ] |WebDevTips Privacy Privacy |
Print This Page

You are here : Home - Web Development - Javascript - Advanced window opener

Advanced window opener



If you have tried the window code generator and need more power then this is the script for you.

Create custom windows with all the features you need.

  • control the window features, toolbars etc
  • choose from 9 screen positions
  • reuse open windows

Known issues
Internet Explorer
The IE resize fix isn't applied to this script - This allows us to open external sites and reuse windows without access errors.
Opera
Due to the way opera can be set up, the script at present opens links in a new window. I will be looking into an opera fix in any future release.

Making it work
If you are familiar with javascript then this should be fairly straight forward, if not, then you should be opening windows like a pro in no time :)

Get the script
Get the script - save as windowopen.js wherever you keep your scripts.

Link to the script
Link to the script from the required page by placing the following code in between the <head></head> tags.


<script language="JavaScript" type="text/javascript" src="windowopen.js"> 
<!-- 
// -->
 
</script>

Opening a window
Don't be put off by the long list of numbers, it's not that complicated really :) a typical link would look like this.


<a href="#" onClick="open_win('URL_TO_OPEN',400,400,1,1,1,1,1,1,1,1,5,'win1');return false;">Page 1</a>

What to change
('URL_TO_OPEN',400,400,1,1,1,1,1,1,1,1,5,'win1')

In detail

  • 'URL_TO_OPEN', - The address of the page to open
  • 400, - window width
  • 400, - window height
  • 1, - Tool Bar 1=On 0=Off
  • 1, - Address Bar 1=On 0=Off
  • 1, - Directories 1=On 0=Off
  • 1, - Status Bar 1=On 0=Off
  • 1, - Menu Bar 1=On 0=Off
  • 1, - Scroll Bars 1=On 0=Off
  • 1, - Resize 1=On 0=Off
  • 1, - Copy History 1=On 0=Off
  • 5, - Window Position 1-9
  • 'win1' - The window name

Tips
When reusing a window you cannot change the window properties so the best thing to do is copy the link and change the URL_TO_OPEN value.

If you are only using 1 fixed size window then you are best using the window code generator



Demo showing positions and reusing windows
Pos No Position Window Name Test 1 Test 2
1 Top Left win1 Page 1 Page 2
2 Top Middle win2 Page 1* Page 2*
3 Top Right win3 Page 1 Page 2
4 Middle Left win4 Page 1 Page 2
5 Middle win5 Page 1 Page 2
6 Middle Right win6 Page 1 Page 2
7 Bottom Left win7 Page 1 Page 2
8 Bottom Middle win8 Page 1 Page 2
9 Bottom Right win9 Page 1 Page 2
* = No toolbars

If you are having any problems or have any questions regarding this script then please post them in the scripts forum.




21-Jul-2003




Google
 

[back to top of page]   

[labelled with icra -  - this link will open in a new window] [RSS Content]

[Copyright © WebDevTips]