By now you should be a dab hand at creating links. If you've followed our tutorials you should be able to create links that open in a new window using target="_blank" However many sites have links to windows that open to a predetermined size, with or without controls or pop up (these popup window are called floating palettes and can be useful or can be a damn pain!!) They rely on Event Handlers & JavaScript to create them (so remember they won't work on older browsers) Lets begin with a simple example. Click on the form button below and another palette opens
<form> The form set up you have seen before. But the onClick function is new. The key JavaScript command is window.open. This tells the browser to open up a file in a new window (here "test.htm" in a window with attributes set to a 200 pixel by 200 pixel size) Notice how there is no scrollbar or menu controls. You can't adjust the size of the box either. Technically you need to do this JavaScript recognises 1 & 0 as yes and no (but it will also recognise yes & no) Luckily both Internet Explorer and Netscape recognise no(0) as a default. (toolbar to directories set various menu bars, then status sets the status bar at the bottom of the window. The scrollbar and resize are self explanatory we hope !!!) Make sure you don't put in extra spaces Substitute your own target URL (we use test.htm here) and change the options as described earlier. You can also replace anythingyouwant, test.htm and newwindow with any values you want. (We describe how to close down windows elsewhere) A slight variation on this theme allowed you to have a window pop up on loading To do this we added the onLoad attribute to the <body> tag <body The onLoad attribute tells the browser to do the following when the HTML document loads up Here onLoad tells the browser to open a window for the URL (defined here as the file nav.htm) which the browser then knows as a window called navwindow (you can use your own name). Okay !! That's the basics !! But how about adding it to a more ordinary link item like a graphic or text e.g. or click here So how did we do it. Here is the code for the <a> tag used for both <a href="test.htm" target="newwin" (note the ,'', after window.open( |