![]() ![]()
JavaScripts - This is your Web site on CaffeineJavaScript is a scripting language developed by Netscape, used to create interactive Web sites. It holds two main attractions for lazy Webmasters.
<A href="http://www.susanives.com/lazy/index.html"onClick="window.open('','popup','height=300,width=200,toolbar=yes,scrollbars=yes')"target="popup">Your link here</A>If you deconstruct this, you'll see several options. First, see that it starts out with a normal link tag, <A HREF>. Here, of course, you put the URL of the HTML document you want to appear in the popup window. It can be a page on your own site (in which case you don't need the http://), or a remote site, as illustrated here. Next, note that you can change the width and height of the popup window. If you delete one or both of these parameters, it will be full screen size. You can also omit the toolbar or the scrollbar by changing the "yes" to "no". I like to keep the scrollbar. You never know what screen resolution your user will have and there's nothing worse than not being able to access content that slopped down below the screen. The toolbar is more of an option; I often leave it off. However, I've found that many people can't figure out how to print a page if they don't have a toolbar (they can right-click and select print), so if you expect the page to be printed, the toolbar is useful. Close Window: Often, if I use a popup, I will include a button to close the window when the user is done with it. If they don't close the window, they end up with a bunch of little windows open. It's confusing. Here's a little script that will create a button that will close a popup window: <form> <input type="button" style="background-color: #000080; color: #FFFFFF; font-weight: bold; font-size: 10pt;" value="Close Window" onClick="window.close()"> </form>The code I have typed in bold is CSS (cascading style sheet) and is optional. If you leave this off, you will get a plain gray button. This code changes the button background to navy blue and the button text to white. Here is a popup window that also has a close window button. If you want to make an automated popup, here is a code generator that will write the Java for you. I hate them and do not use them. Not all JavaScripts are this straightforward. Some require you to put some of the code nested in the <HEAD> tag, some within the <BODY> tag and the rest under the <BODY> tag. A few require that you upload graphics or other files to your server. The instructions for most of them are quite clear, however - just follow them carefully. Many JavaScripts are long and would take pages and pages to reproduce here. Here are some examples:
Flying objects: This will take a transparent gif image and fly it around on your screen. You can have the code mailed to you by going to www.a1javascripts.com/page_effects/flyingimage/flyingimage.html. You can use any image you want: I used a butterfly. You can view it in this popup window.
The catch: There's always a catch. JavaScripts may not work with all browsers, or may not work in the same way. Some people disable Java in their browsers. More than one script per page may confuse browsers. Some scripts are evil (like ones that won't let you leave a page until you click a sponsor's link) and some are cute the first time, irritating with repeated exposure. Use them judiciously, test them thoroughly. Susan Ives is a former president of Alamo PC. She archives these columns on her Web site, susanives.com. If you visit, you can cut-and-paste the code instead of retyping it from the magazine - the ultimate in lazy Webmastering! ![]() |