Graphic Design / Interactive Design / Fine & Applied Arts / Parkland College

Graphic Design Student Handouts:
Code Snippets

Dreamweaver writes wonderful code for you, but it can't do everything. Sometimes, the only way to achieve a specific effect is write custom code or to copy and paste the code into Dreamweaver manually. The following snippets might come in useful.

Phantom Scroll Bar Fix

You may have noticed that when clicking from a long web page (with a scroll bar) to a short web page (without a scollbar) will cause page elements to "shift." One solution is to add a "phantom" scroll bar on the right regardless of whether there is enough content to warrant it. The following CSS will accomplish this:

html {overflow-y:scroll;}

Close Window

This Javascript code can be added to a link which will close the current window when clicked. This is especially useful when creating pop-up windows.

Open links in new window/tab

Adding target="_blank" to links may not be supported in future releases of HTML. If you still want a link to open up in a new window/tab, here is a Javascript alternative.

Pop up Windows

Dreamweaver has a built-in behavior to open browser windows at a specific size. Unfortunately, it requires that you use "#" as the link, which will scroll your main page back to the top (unless you start adding named anchors). An alternative is to use the following code instead (which also happens to be accessibility friendly).

Open Page in Frameset

If a page is intended to be opened only within a frameset, this script refers the browser immediately to the frameset page.

BACK TO TOP
Last updated: 1/14/17 ■ Webmaster: Paul Young